WEBVTT 1 00:06:17.634 --> 00:06:19.403 Left front right? 2 00:08:48.658 --> 00:08:55.019 Okay. 3 00:08:55.019 --> 00:09:01.948 You heard typing. 4 00:09:11.969 --> 00:09:16.739 Silence. 5 00:09:16.739 --> 00:09:25.109 Silence. 6 00:09:25.109 --> 00:09:28.229 Okay. 7 00:09:28.673 --> 00:09:39.624 Can you still hear me? Thank you, Dan? I don't. Everything looked fine from my end. I ask. Can you hear me? It's a today. You cannot hear me. 8 00:09:39.624 --> 00:09:44.124 So I log out and log in again and restarted everything and. 9 00:09:47.158 --> 00:09:52.708 That resets things it just takes a little. Okay so you should be able to. 10 00:09:52.708 --> 00:09:56.788 To my screen. 11 00:09:59.009 --> 00:10:03.389 Silence. 12 00:10:03.389 --> 00:10:07.558 Okay, so we'll see if something is happening. 13 00:10:08.609 --> 00:10:14.849 So, the theory is that you can hear me and also see my screen. 14 00:10:14.849 --> 00:10:19.139 And see my screen. 15 00:10:19.139 --> 00:10:25.379 Okay, I was also trying to share my iPad, but. 16 00:10:27.264 --> 00:10:39.474 I may maybe too dangerous to try that actually. So parallel class, 25th, 2021, what is happening now, is we're 1 last day or half a day on thrust and then. 17 00:10:42.509 --> 00:10:52.528 No screen share yet so as I'm sharing my screen. 18 00:10:52.528 --> 00:10:58.859 Okay, Eva. Okay. 19 00:11:00.389 --> 00:11:03.509 The only way I can get this done is. 20 00:11:05.639 --> 00:11:11.788 Think this. 21 00:11:14.668 --> 00:11:21.658 Is it can you see my screen now? 22 00:11:25.769 --> 00:11:29.759 My end claims that I'm sharing. 23 00:11:33.658 --> 00:11:38.999 And you see my screen than any 1. 24 00:11:38.999 --> 00:11:43.499 You cannot. 25 00:11:46.198 --> 00:12:51.749 Silence. 26 00:12:56.428 --> 00:13:01.948 Silence. 27 00:13:05.489 --> 00:13:11.489 Okay, can you hear me now? Can you see my screen now? 28 00:13:11.489 --> 00:13:19.139 This is starting to get stupid. 29 00:13:21.089 --> 00:13:25.408 You can hear me, but the screen is still blank. 30 00:13:28.318 --> 00:13:33.778 So, I've logged out I've logged in, I have, um. 31 00:13:40.198 --> 00:13:49.619 Still blank let me. 32 00:13:54.298 --> 00:13:58.589 How is this. 33 00:13:58.589 --> 00:14:04.798 Can you see this now? 34 00:14:17.278 --> 00:14:20.609 Okay, uh. 35 00:14:20.609 --> 00:14:30.479 My best guess is the computers are slow today. It's, I say sharing and it takes a while to share. Okay. So. 36 00:14:32.219 --> 00:14:36.418 10 minutes into the class finally. 37 00:14:36.953 --> 00:14:49.734 From my end, everything looks fine. The 1st time is I log out and log in to get entry initializes the display drive for a 2nd time. I just killed Firefox and started again retreat. initializes Webex. 38 00:14:50.004 --> 00:14:52.793 And which is sometimes necessary to get to sharing working. 39 00:14:53.158 --> 00:14:57.899 Okay, so from guilty thrust and then. 40 00:14:59.668 --> 00:15:02.818 And then maybe do some. 41 00:15:04.048 --> 00:15:08.278 Maybe do some, um. 42 00:15:08.278 --> 00:15:12.808 So. 43 00:15:12.808 --> 00:15:17.969 Quantum computing, but let me see if I just want to. 44 00:15:17.969 --> 00:15:23.489 See, if I could get us play working. 45 00:15:24.869 --> 00:15:36.028 Silence. 46 00:15:36.028 --> 00:15:39.958 Okay. 47 00:15:43.739 --> 00:15:47.489 So. 48 00:15:47.489 --> 00:15:52.798 Something is actually working now. 49 00:15:52.798 --> 00:15:56.908 I decided it would be useful to write a few things down. 50 00:15:56.908 --> 00:16:01.828 So. 51 00:16:02.969 --> 00:16:08.489 To show you some things if I bring up, for example. 52 00:16:08.489 --> 00:16:11.969 Mode to count the number of unique keys. 53 00:16:11.969 --> 00:16:15.808 And. 54 00:16:15.808 --> 00:16:19.739 Let me give you an idea of how we can do it here. So. 55 00:16:19.739 --> 00:16:25.708 Okay. 56 00:16:36.808 --> 00:16:43.649 Well. 57 00:16:57.359 --> 00:16:57.479 Okay, 58 00:16:57.533 --> 00:17:14.034 Eva. 59 00:17:15.209 --> 00:17:19.318 Hello. 60 00:17:19.318 --> 00:17:23.128 Okay. 61 00:17:23.128 --> 00:17:36.989 Okay, so to show you, how you can then bring this up here is when I mirror my, it has that black margin border around the left and right that. 62 00:17:39.358 --> 00:17:42.959 That is. 63 00:17:42.959 --> 00:17:47.578 It is impossible to delete so far as I know. But okay, so what we're trying to do is. 64 00:17:47.578 --> 00:17:57.568 We're trying to count the numbers unique keys. So if I've got some sort of string here, and it doesn't even have to be sorry will make it sorry to say. 65 00:18:03.449 --> 00:18:11.398 Okay, and we want to count it over unique case. Well, here there are 7. I mean, I just made it easy. 66 00:18:11.398 --> 00:18:18.808 What we affect the way we do it is that we shift everything to the right 1. 67 00:18:30.173 --> 00:18:41.213 No, we don't really shifted right? But we're using our smart. We're, we're using our smart again and now we've got we have these 2 vectors here and here. 68 00:18:41.489 --> 00:18:46.828 And we're doing the dot product of them, but, you know, so it's. 69 00:18:46.828 --> 00:18:52.558 Product, but your your usual dot product. 70 00:18:52.558 --> 00:18:55.769 Has times and plus. 71 00:18:57.749 --> 00:19:02.338 Here we're going to have not equal and plus. 72 00:19:02.338 --> 00:19:11.638 Okay, so we're going to have here cases where they're not equal is going to be oops. 73 00:19:12.838 --> 00:19:25.229 Let me put that back was a 1 here and that say to wanted this 1. okay. Places where they're not equal. Are here. 74 00:19:26.608 --> 00:19:30.209 Here here here. 75 00:19:30.209 --> 00:19:35.009 And here, so so we do the. 76 00:19:36.388 --> 00:19:47.939 We do the not equal element by element and it's going to be 001001001010 1. okay. And we some, that. 77 00:19:48.443 --> 00:20:00.534 And we're going at 12345 and that counts. Well, there's, there's an off by 1 thing at each end, basically, but you see, it's counting every time we get a transition from 1, run to another run. So. 78 00:20:11.098 --> 00:20:17.068 Between runs and then some equals the number of runs. 79 00:20:17.068 --> 00:20:22.348 And of course, it runs in parallel. 80 00:20:22.348 --> 00:20:30.598 Okay, so if we look at look at the code here, let's say. 81 00:20:36.058 --> 00:20:40.138 Make it a touch bigger and. 82 00:20:47.009 --> 00:20:51.568 Okay, so what is happening down here. 83 00:20:55.588 --> 00:20:59.489 So, it generating some random data up here. 84 00:20:59.489 --> 00:21:03.509 And let me bring the. 85 00:21:06.298 --> 00:21:11.038 You can only see the course Web site right now. 86 00:21:11.038 --> 00:21:16.288 Okay, let me show you. 87 00:21:20.278 --> 00:21:25.169 Sharing my screen. 88 00:21:28.019 --> 00:21:32.429 This again. 89 00:21:43.499 --> 00:21:52.679 Do you my screen anyone? Can you see my screen? Can you reply? No. 90 00:21:52.679 --> 00:22:02.368 Try to something different here. 91 00:22:02.368 --> 00:22:08.338 Now, yes. 92 00:22:08.338 --> 00:22:14.459 I used a slightly different VERT thing inside Webex. Okay. Let me come back to the. 93 00:22:14.459 --> 00:22:24.689 Here we go. Okay, so this is what you couldn't see before we have a string here that I wrote in black. 94 00:22:25.888 --> 00:22:31.439 And let me actually okay. 95 00:22:33.028 --> 00:22:44.878 So, what we have here is a string in black, it's got a lot of runs in it, and I want to count the number of runs of different elements. So I take the string and I shifted right. 1, and I wrote it in blue now. 96 00:22:44.878 --> 00:22:55.469 And now, when I look for corresponding elements are different. 1 equals 11 equals. 11 does not equal to I shaded in yellow tweak was to tweak those 2 3. 97 00:22:55.469 --> 00:23:02.548 And, whoops, I was 1 more that I missed. That's 1 reason. My count was off. 98 00:23:04.199 --> 00:23:08.578 Who does not equal 3 that's 1 more. Who else did I miss? 99 00:23:08.578 --> 00:23:12.628 Okay, so 6. 100 00:23:12.628 --> 00:23:27.449 Okay, in any case I've highlighted in yellow the places where corresponding elements are different corresponding 1 element is from the string of ron's. The 2nd element is from the string of ones. Right? Shifted 1. 101 00:23:28.013 --> 00:23:35.423 Okay, and now I sum up the differences. So this is doing a DoD product, but the normal DoD product is times. 102 00:23:35.423 --> 00:23:46.943 And plus this is a DoD product of not equal and plus and cases where they're differing are 6 as off by 1 issue. So, the total of 7 runs. Okay. 103 00:23:49.138 --> 00:23:52.558 Back to here, if you can see my. 104 00:23:52.558 --> 00:23:56.848 Terminal window is this is the program. 105 00:23:56.848 --> 00:24:02.278 Generate the data copy the data to the device. 106 00:24:04.229 --> 00:24:08.999 Print the data by just copying into an outstream it or 8 or. 107 00:24:10.229 --> 00:24:13.798 The data generated was random. 108 00:24:14.844 --> 00:24:17.273 So this sorts, the data okay. 109 00:24:17.273 --> 00:24:32.034 Does the sort on the device and the way we know it's done on the device is because the pointer here the is, is a device it's on the device and so this compile time dispatching this compiles a call to the device. 110 00:24:32.064 --> 00:24:32.483 Sort. 111 00:24:33.989 --> 00:24:42.239 Printed out again, and here is the 1 statement that does all the work. 112 00:24:43.409 --> 00:24:48.509 Here is our initial data, we're saying, minus 1 at the end. 113 00:24:48.509 --> 00:25:01.769 And because we're comparing each element to the element 1, after that. So we're not comparing the last element to anything. So, this is beginning and ending to the initial factor. 114 00:25:01.769 --> 00:25:06.449 Here's the factor shifted, right 1 we just add 1 to the. 115 00:25:06.449 --> 00:25:11.699 Begin so it's a dot product. 116 00:25:11.699 --> 00:25:19.288 This is the element to element combination operator and it's an equal. 117 00:25:19.288 --> 00:25:22.469 So this not equal to. 118 00:25:22.469 --> 00:25:26.939 Will take 2 arguments, which will be 2 and return. 119 00:25:26.939 --> 00:25:34.949 Building, which converts to an end. So this is what compares to corresponding elements. This is what. 120 00:25:34.949 --> 00:25:39.868 Reduces and just the initial value for the reduce. So the output here. 121 00:25:39.868 --> 00:25:46.348 Is a number of unique elements. Okay. 122 00:25:48.598 --> 00:25:51.719 Now, what happens next. 123 00:25:51.719 --> 00:26:01.138 So, what we had up here, this big statement counted the number of runs. Now we want to learn what are the keys and what are the lengths of each fraud. 124 00:26:02.159 --> 00:26:07.679 So, we constructive factor big enough to hold all the keys as some unique number of them. 125 00:26:07.679 --> 00:26:15.449 This is the games of the keys that constructive vector to hold the length of each the count the Instagram. 126 00:26:16.828 --> 00:26:20.548 And now we do a reduced by key. 127 00:26:22.259 --> 00:26:31.949 Now, reduce by key. Now, this is a little interesting here. What's happening here what we're reducing is a, we're just reducing a vector of ones. 128 00:26:31.949 --> 00:26:38.368 And each element in this factor has a key attached to it. 129 00:26:39.509 --> 00:26:49.558 But the key is our sort of data so we're treating the run the elements in the run as sorted. 130 00:26:50.999 --> 00:27:00.058 Assorted data, and we're using them to do a reduce but what what reduced by key does is it. 131 00:27:00.058 --> 00:27:05.878 Adds up elements in here for which the key is the same. 132 00:27:05.878 --> 00:27:10.019 So, let me show you, what's happening here. 133 00:27:10.019 --> 00:27:14.429 Okay, assuming you can see my. 134 00:27:14.429 --> 00:27:18.628 Um. 135 00:27:18.628 --> 00:27:21.929 Page. 136 00:27:21.929 --> 00:27:25.378 Let me rewrite this initial vector again. 137 00:27:27.328 --> 00:27:33.388 It is 111223444 or 5 5. 138 00:27:33.388 --> 00:27:36.659 6, 6. 139 00:27:36.659 --> 00:27:40.558 Okay, so this is now keys. 140 00:27:40.558 --> 00:27:44.548 Our data is going to be all ones. 141 00:27:49.888 --> 00:27:54.298 Data, so we're reducing. 142 00:27:54.298 --> 00:28:00.203 By key, we're summing up the data for runs, which have the same key. 143 00:28:00.653 --> 00:28:10.523 So there's a barrier here a barrier here barrier here here here here there and now inside each region, 144 00:28:10.523 --> 00:28:14.544 which has the same key or summing up the data we get 3, 145 00:28:14.574 --> 00:28:15.713 2 13223. 146 00:28:18.058 --> 00:28:21.269 And that is. 147 00:28:21.269 --> 00:28:28.378 That's the length of each run and by the way it's all done in parallel. So some. 148 00:28:34.888 --> 00:28:38.939 Time equals log in. 149 00:28:38.939 --> 00:28:42.749 Okay, so. 150 00:28:44.308 --> 00:28:50.308 So, we don't just want to know the links who want to know the keys themselves in each run. So, go back to the code here. 151 00:28:52.108 --> 00:28:56.459 So reduced by key does so it has these input. 152 00:28:56.459 --> 00:28:59.969 Inputs to reduce by key are the keys. 153 00:28:59.969 --> 00:29:06.719 The data output are the vector of unique keys. 154 00:29:06.719 --> 00:29:17.128 And the vector of the count's so reduced by key reduces the string of runs of unknown variable length. 155 00:29:17.128 --> 00:29:21.749 It's very, it's very useful and we write everything out. 156 00:29:22.979 --> 00:29:25.979 Now, if I dare try to compile it. 157 00:29:26.999 --> 00:29:38.848 Given my luck today. 10 seconds. 158 00:29:38.848 --> 00:29:41.878 Is slow. 159 00:29:41.878 --> 00:29:47.159 And so random data, it sorted that. 160 00:29:47.159 --> 00:29:51.148 And the values and accounts, there were 6 nines for example. 161 00:29:51.148 --> 00:29:55.288 So that's showing how reduced by key. So. 162 00:29:55.288 --> 00:30:01.798 Even though we're spreading stuff out among a lot of parallel course, we can still handle runs of all different lanes. 163 00:30:03.449 --> 00:30:07.528 Show another example here say word count. 164 00:30:08.969 --> 00:30:21.868 Similar sort of thing we want to count the number of words, and a text sample, and we're using the same sort of inter, product idea. Just a number of runs. We're looking for transitions. 165 00:30:21.868 --> 00:30:24.898 From a word to a not a word. 166 00:30:24.898 --> 00:30:33.538 And each time is a transition from a letter to not a letter that's the end of a word and we count it up. We have the number words in the. 167 00:30:33.538 --> 00:30:38.459 Document so is alpha. 168 00:30:38.459 --> 00:30:42.058 Cheques if a character is part of a word. 169 00:30:44.128 --> 00:30:51.838 And this is just it's overloading operator per, and it could be done much better with placeholder notation or Lambda. 170 00:30:51.838 --> 00:30:57.479 But it just returns to that. 171 00:30:57.479 --> 00:31:00.598 Um. 172 00:31:00.598 --> 00:31:09.179 Well, it takes 2, it takes parties. The 2 characters it takes 2 argument to your point is to 2 characters and returns. Is that. 173 00:31:09.179 --> 00:31:12.778 Where all this is transitioning from not a letter to a letter. 174 00:31:14.068 --> 00:31:19.078 And all the work is happening down here, which is in our product. 175 00:31:19.078 --> 00:31:24.328 Make it as wide as possible to try and help you. Okay so. 176 00:31:24.328 --> 00:31:29.068 Again is the character. 177 00:31:29.068 --> 00:31:32.459 You know, are we transitioning between word and not a word. 178 00:31:32.459 --> 00:31:44.939 And summing up the number of cases and so all the work is done in 1 line. Really? Because we couldn't put the other stuff in line is where it start that could have been put in line with placeholder notation. 179 00:31:44.939 --> 00:31:53.459 And and we add 1 and so this shows, this sort of notation is really it's really compact. 180 00:31:53.459 --> 00:31:57.568 And executes fast, and we could try making this thing. 181 00:31:57.568 --> 00:32:02.729 11 seconds later. 182 00:32:04.469 --> 00:32:15.598 For a 2nd layer I'll take, I'll believe them notice 50, 65 for it. You can check that for me. 183 00:32:17.338 --> 00:32:25.259 Okay, so stuff like that repeated range. 184 00:32:26.788 --> 00:32:31.888 I think I showed you last time again. 185 00:32:34.858 --> 00:32:38.249 Well, let me show you just to remind you. 186 00:32:39.838 --> 00:32:44.009 How repeated range works I'll just show you, it's run it and show you. 187 00:32:44.009 --> 00:32:47.098 Um. 188 00:32:55.019 --> 00:33:08.489 And just to remind you, because it's a powerful idea also it's worthwhile repeating powerful ideas. 189 00:33:08.489 --> 00:33:12.868 And, okay, so. 190 00:33:12.868 --> 00:33:16.318 So, here's our input, whatever. 191 00:33:19.469 --> 00:33:24.659 Whatever, and we want to. 192 00:33:24.659 --> 00:33:28.019 And so you might say the. 193 00:33:29.969 --> 00:33:34.949 Input input you might say. 194 00:33:36.989 --> 00:33:44.159 Would be like 0123 and so on. That's the input. Now what we want is the output. 195 00:33:44.159 --> 00:33:47.608 Say we repeat it twice or something. 196 00:33:50.098 --> 00:33:55.949 So the output. 197 00:33:58.469 --> 00:34:02.189 Our, um. 198 00:34:03.479 --> 00:34:09.989 And so on, so basically. 199 00:34:12.778 --> 00:34:19.528 You know, you might say out it so by is I divided by 2. 200 00:34:19.528 --> 00:34:26.009 Okay, so what we want to do is we want to take the counting. 201 00:34:30.659 --> 00:34:37.739 Divided by 2, and get into a gather. 202 00:34:39.239 --> 00:34:44.728 Gather on the input 00, tell them and 1010. 203 00:34:47.099 --> 00:34:51.449 So, you see, the work that we're doing is. 204 00:34:51.449 --> 00:35:01.079 Put this up again in case, anyone has a comment you see what we're doing is we're doing work on a vector of indices and. 205 00:35:03.568 --> 00:35:07.708 So, basically. 206 00:35:07.708 --> 00:35:14.338 We modify embassies. 207 00:35:15.748 --> 00:35:19.079 Powerful idea. Okay. 208 00:35:19.079 --> 00:35:22.438 So, that's what we're talking about here. 209 00:35:22.438 --> 00:35:32.219 Okay, I'll repeated range I showed you that. I showed you those 2 before other examples in here are. 210 00:35:34.889 --> 00:35:40.469 You to do set operations I talked about quickly. 211 00:35:43.619 --> 00:35:47.938 Okay, I'm going to show you. 212 00:35:47.938 --> 00:35:54.539 Well, vertices. Okay. 213 00:36:02.128 --> 00:36:07.768 Okay, so this is working with, say, mention geometry and. 214 00:36:10.048 --> 00:36:19.228 Our input is that we've got this mesh with triangles. 215 00:36:19.228 --> 00:36:23.009 And that we want to. 216 00:36:24.809 --> 00:36:30.778 We want to find vertices that are duplicated and combine them together. So. 217 00:36:32.188 --> 00:36:36.568 So, the input here, it's a mesh with 3 triangle. Let me. 218 00:36:38.188 --> 00:36:43.588 I'm trying to push the okay. I got a corner. 219 00:36:44.123 --> 00:36:58.884 Of the chat window open in case, you want to chat so input we've got 3 separate triangles, which happened to form a mesh. Okay. Triangles arrow has vertices. 01 and 2 triangle 1 has vertices 3. 220 00:36:59.548 --> 00:37:13.798 4 and 5 and triangle 2 has where it is triangle 200 before, and then next triangle 1 vertices, 67 and 8. but some of these vertices are the same. Vertex 1 is the same as vertex 3 and so on. 221 00:37:13.798 --> 00:37:16.798 And we wish to. 222 00:37:16.798 --> 00:37:20.668 Combine them here, so, at the top we've got like. 223 00:37:20.668 --> 00:37:24.148 9 separate vertices at the bottom. 224 00:37:26.759 --> 00:37:34.889 We basically have 5 vertices because each vertexes used a couple of times and the top, and we want to compute that thing. 225 00:37:34.889 --> 00:37:41.909 Okay, so while these 3 isolated triangles into a mesh. 226 00:37:43.978 --> 00:37:49.739 And how do we do that? 227 00:37:50.969 --> 00:37:57.418 Forward we're type staffing a few things, I would make it a class, but okay so a toball. 228 00:37:57.418 --> 00:38:05.759 Of 2 floats and again, the reason you use a 2 full, instead of a vector of 2 floats is the vector has overhead. 229 00:38:05.759 --> 00:38:13.980 And, um, and you don't want overhead, you don't want a lot of small vectors, the overhead. It's just too much. Okay so. 230 00:38:15.539 --> 00:38:20.789 So, what we have is that the triangle originally have coordinates. 231 00:38:20.789 --> 00:38:26.849 So, if I can scroll up a little, we have the for each for our tax here. We have its coordinates of its 3. 232 00:38:26.849 --> 00:38:34.860 As a few vertices and each triangle, and the way will identify the vertexes you is more than a 1 says there'll be 2 vertices that have the same coordinates. 233 00:38:34.860 --> 00:38:46.500 Okay, so here we just guide this and these, the C plus plus and tax here. If you're weak on C. plus plus is this is constructing a new variable uptight to. 234 00:38:46.500 --> 00:38:50.070 It's a constructor and, um. 235 00:38:50.070 --> 00:38:58.289 It's like a function to function name is the class name, the type name and the arguments or arguments that go into the. 236 00:38:58.289 --> 00:39:03.420 For the constructor now you have something like a 2 pull here. 237 00:39:05.010 --> 00:39:08.909 Uh, well, back to is a twofold up here. 238 00:39:09.175 --> 00:39:18.894 Then the default constructor will do the obvious saying, it will take 2 floats in constructive act 2 by the way as C. 239 00:39:18.894 --> 00:39:24.204 plus plus advances through the years, these default constructors actually get more and more intelligent. 240 00:39:24.539 --> 00:39:31.079 Okay, so is for each for tax the, all the vertices and the data set are. 241 00:39:31.079 --> 00:39:34.440 1 device factor it's a device factor effect. Twos. 242 00:39:34.440 --> 00:39:43.110 And there's 9 of them and inputs the name of the variable and again, the constructor here, there's lots of different possible constructors for. 243 00:39:43.110 --> 00:39:46.980 Vector is this if it's an editor that gives a number of elements. 244 00:39:48.539 --> 00:39:58.500 And here, we go assigning them, you could also in currency plus plus collapse that, and put all of the 2 strong out in 1 command. 245 00:39:59.730 --> 00:40:07.559 Okay on the output mash. Um. 246 00:40:08.670 --> 00:40:14.400 We don't know how big the output match for me. So we just say output, vertices and output indices. 247 00:40:15.599 --> 00:40:26.400 Okay, so vertices here so it copied the input to the output. Okay so these are all the vertices. 248 00:40:26.400 --> 00:40:30.539 Sorting then brings them together if they've got the same coordinates. 249 00:40:30.539 --> 00:40:34.050 So, again, this is assuming that the sort consort. 250 00:40:34.050 --> 00:40:40.860 2 balls floats and do the sensible thing if it didn't, you'd have to give it a comparison predicate. 251 00:40:40.860 --> 00:40:44.639 The comparison, but it does the right thing here. 252 00:40:45.900 --> 00:40:55.110 Okay, now here's a unique here's a new function for you. Unique. 253 00:40:55.110 --> 00:41:00.389 So, unique unique takes. 254 00:41:00.389 --> 00:41:06.480 A vector which may have duplicates in it and it compresses it out. 255 00:41:06.480 --> 00:41:11.820 To remove the duplicates. So if I can show you my. 256 00:41:11.820 --> 00:41:16.110 That would be. 257 00:41:17.639 --> 00:41:22.619 So unique. 258 00:41:24.719 --> 00:41:29.820 Well, if I use my previous, so if I just have some sort of vector. 259 00:41:34.710 --> 00:41:41.250 Something like that and unique will give 1, 2, 3. 260 00:41:42.389 --> 00:41:48.480 4 or 5, and compresses them out and it compresses them out in place. 261 00:41:48.480 --> 00:41:55.469 Okay, and that's unique here. 262 00:41:57.960 --> 00:42:06.510 Now, what unique also does is it updates the end 2.21 after the end so. 263 00:42:08.039 --> 00:42:14.010 Bring back here, so the new this is now that began and this is now the end that. 264 00:42:14.010 --> 00:42:17.039 So, unique crunches stuff down. 265 00:42:17.039 --> 00:42:23.070 In parallel always and gives you an updated ended or so, you know. 266 00:42:23.070 --> 00:42:29.639 You know how much there is okay. 267 00:42:30.809 --> 00:42:35.550 Thrust unique and vertices thought and gets updated. 268 00:42:35.550 --> 00:42:40.650 And what a race does is, it goes. 269 00:42:40.650 --> 00:42:44.219 And just erases the elements after the. 270 00:42:44.219 --> 00:42:47.550 After the end thing, so just. 271 00:42:47.550 --> 00:42:52.650 Returns the space, if it's you have to check the apprentice sizing here. 272 00:42:52.650 --> 00:42:57.570 So that gets and that gets. 273 00:42:57.570 --> 00:43:06.360 So raises a good thing to do after unique. Okay. Now a lower bound does. 274 00:43:06.360 --> 00:43:13.889 It lower bound now, it gets coming so lower ground. This is this crunched down unique. A 5 factor. 275 00:43:13.889 --> 00:43:17.280 This is the input factor. 276 00:43:17.280 --> 00:43:24.210 Now, what lower bound does I showed it before? But it's complicated. If it's worthwhile looking at it again. 277 00:43:27.179 --> 00:43:37.409 Lower bound goes and finds for each element of the crunched vector appears in the original vector. So that goes there that goes there. 278 00:43:37.409 --> 00:43:42.150 It goes there and that goes there. 279 00:43:42.150 --> 00:43:51.300 Okay, so it finds a lower bound. So the long vector has to be sorted and it goes where each run. 280 00:43:51.300 --> 00:43:57.449 Or it finds the 1st case in the small vector where it occurs in the big factor. 281 00:43:58.469 --> 00:44:02.070 And if it doesn't occur at all of it finds the 1st case of a larger thing. 282 00:44:02.070 --> 00:44:06.449 So, again, we saw this before something with Ron. 283 00:44:06.449 --> 00:44:09.690 Run lanes and Cody going around steep coating. 284 00:44:09.690 --> 00:44:13.260 And again, guess what happens in parallel. 285 00:44:13.914 --> 00:44:16.795 So, lower bound can go and find where all the run start. 286 00:44:17.244 --> 00:44:32.215 So, again, their online thing, the small vector of unique things are the keys for each run and the large vector is all the runs spread out and this lower bound finds where each run starts conditions. 287 00:44:32.215 --> 00:44:34.344 Are is that everything has to be sorted. 288 00:44:34.650 --> 00:44:40.139 That's lower bound and. 289 00:44:44.670 --> 00:44:48.750 And so what this does is it found the duplicated vertices. 290 00:44:48.750 --> 00:44:55.980 And then it writes them out. 291 00:45:05.670 --> 00:45:11.550 And, um. 292 00:45:13.650 --> 00:45:24.480 It's just saying here indices, so these are the, and these are each original vertex. 293 00:45:24.480 --> 00:45:29.940 And what is unique abide number is so again. 294 00:45:29.940 --> 00:45:35.070 What we had was. 295 00:45:35.070 --> 00:45:41.369 3 triangles and each triangles. Vertex has its coordinates. 296 00:45:41.369 --> 00:45:49.170 But the fact that a triangle down may be used in a couple of Vertex they've used in a couple of triangles isn't known. We have to determine that. 297 00:45:49.170 --> 00:45:52.829 So, great X1, 3 and 6 hallo the same coordinates. 298 00:45:52.829 --> 00:45:58.800 And and swelled vertices. 299 00:45:58.800 --> 00:46:03.059 A bind says send. 300 00:46:03.059 --> 00:46:10.320 So, we can find duplicate versions for cases of the same coordinates. I use in more than 1 triangle. 301 00:46:10.320 --> 00:46:18.420 Okay. 302 00:46:18.420 --> 00:46:21.449 Okay, it's. 303 00:46:22.679 --> 00:46:27.750 Summary statistics. 304 00:46:27.750 --> 00:46:31.349 Um. 305 00:46:35.159 --> 00:46:48.960 Okay, this is going to show you the reduce operator, but the reduce operator being doing computing several things at once we saw reduce computing sums. 306 00:46:48.960 --> 00:46:56.639 Here it reduces going to compute min and Max and sums and some moments and so on all at once. 307 00:46:57.659 --> 00:47:02.699 How do we do this? We define a new type called summary stats data. 308 00:47:02.699 --> 00:47:07.619 And it's got all of these elements in it. 309 00:47:09.150 --> 00:47:15.809 And it's templated, so it could be summarizing it or doubles. 310 00:47:15.809 --> 00:47:19.500 And the initialize are. 311 00:47:19.500 --> 00:47:26.909 Just initial law, and you can guess so, this is going to be accumulating mean men's accumulating. Max says. 312 00:47:26.909 --> 00:47:32.219 For accumulating means we are going to sum it up in divide by end this accumulating account. 313 00:47:32.219 --> 00:47:39.030 So, initialize them all to the obvious thing means that ends we Initialized to 0. 314 00:47:39.030 --> 00:47:45.269 Men, we should initialize to the maximum possible number and Max, we initialize to the minimum possible number. 315 00:47:45.269 --> 00:47:53.519 And these are higher order moments initialize. 0. so what is the largest possible? And or float. 316 00:47:53.519 --> 00:48:00.300 There's actually an official way to find it. It's in the standard template library. It's numerical limits. 317 00:48:00.300 --> 00:48:05.940 And numeric limits, Max will get the max. We'll get the man and so on. 318 00:48:05.940 --> 00:48:11.969 So, if you want to write clean program and get your biggest and small percentage, or or. 319 00:48:11.969 --> 00:48:17.190 Flow toward toggle. This is the way to do it a numerical. I'm at. 320 00:48:17.190 --> 00:48:20.519 Template it on the mode and so on. 321 00:48:21.539 --> 00:48:27.869 Okay, so this initializes, this class, which. 322 00:48:27.869 --> 00:48:31.619 Accumulates like 7 different things at once. 323 00:48:31.619 --> 00:48:38.909 And to return variances, and so on these are. 324 00:48:38.909 --> 00:48:43.679 Class functions to M2 is almost squares. 325 00:48:44.994 --> 00:48:57.565 And I have a complaint about their formulas here, but this is reserves that for our probability class. 326 00:48:57.864 --> 00:49:02.514 This is computing, an uncensored mall, but not a centered moment. 327 00:49:04.619 --> 00:49:08.159 So well, it depends what we're doing with them, too. 328 00:49:09.329 --> 00:49:12.840 So, okay. 329 00:49:16.289 --> 00:49:20.190 Okay, here's a urinary off which. 330 00:49:20.190 --> 00:49:23.849 Whatever initializes everything. 331 00:49:25.920 --> 00:49:29.039 This binary off. 332 00:49:31.679 --> 00:49:35.849 Combines to summary stats things. So what's going to happen is this. 333 00:49:35.849 --> 00:49:42.420 We take an element of our data set. We're going we're from our element of our data set. We're going to construct. 334 00:49:42.420 --> 00:49:45.989 1 of the summary stats. 335 00:49:45.989 --> 00:49:55.889 Variables everything being Initialized properly, and then we combine to summary stats variables to make a 3rd 1, which has the obvious things done. 336 00:49:55.889 --> 00:50:05.730 The accounts get added the men's, get men, the maxes get maxed the means get added because that means are really just the sum so far. 337 00:50:05.730 --> 00:50:09.030 Until we divide by N. okay. 338 00:50:11.519 --> 00:50:23.219 Um, and again, down here, we're doing a final count calculating statistics. Okay. So the interesting thing happens in the. 339 00:50:24.389 --> 00:50:28.380 Okay, transform reduce. Okay. 340 00:50:30.000 --> 00:50:33.599 Okay, so the data here there is our data. 341 00:50:35.190 --> 00:50:40.590 Are unitary off, takes data elements and transforms them. 342 00:50:40.590 --> 00:50:48.750 To the summary stats elements again, which have these 7 to the count them in the maximum things. So you'd area. 343 00:50:48.750 --> 00:50:53.010 Transforms 1 data element to this clot type destructive. 344 00:50:53.010 --> 00:50:56.639 7 different things and binary off. 345 00:50:56.639 --> 00:51:00.929 Combines 2 of these statistics elements. 346 00:51:02.849 --> 00:51:06.480 I haven't looked at the binary off yet. It's up here. 347 00:51:06.480 --> 00:51:11.579 Ate the name binary off, but hey, didn't ask me. 348 00:51:16.019 --> 00:51:19.260 Are going to go here. 349 00:51:21.090 --> 00:51:24.239 How does it combine them? It adds. 350 00:51:24.239 --> 00:51:30.329 Oh, okay it adds to and and, um. 351 00:51:30.329 --> 00:51:35.010 It means to men's and have access to a Max says. 352 00:51:35.010 --> 00:51:42.179 The mean, it updates weird the way you can figure it out. 353 00:51:42.179 --> 00:51:46.320 Okay, and that that's all the work happens and. 354 00:51:46.320 --> 00:52:00.269 1 line transform, reduce, transform, reduce, takes of vector of data. It transforms each element and then it does a reduce it fuses to transform and reduce. No extra memory needed. 355 00:52:00.269 --> 00:52:03.630 And it writes everything out at the end. 356 00:52:03.630 --> 00:52:07.769 Let's try it. 357 00:52:07.769 --> 00:52:16.230 Silence. 358 00:52:16.230 --> 00:52:22.349 Yeah. 359 00:52:22.349 --> 00:52:26.039 Okay, weird. 360 00:52:26.039 --> 00:52:31.260 Compact again, you see my lesson here is this. 361 00:52:31.260 --> 00:52:39.900 Functional programing it's a cool idea and you can do surprising things with reductions and transformations and so on. 362 00:52:39.900 --> 00:52:46.349 Hey, I'm a. 363 00:52:47.670 --> 00:52:55.559 You may have been thinking that my examples have been too simple for you. You're bored because this is too easy. 364 00:52:56.670 --> 00:53:03.420 Let me show you and transform and put it or. 365 00:53:04.980 --> 00:53:09.780 No, there's no comments here. Okay. 366 00:53:11.460 --> 00:53:15.449 Maybe I should go down to the main program. 1st. 367 00:53:15.449 --> 00:53:23.880 Okay, see, you read see program people's platforms bottom to top because the main programs at the bottom. 368 00:53:24.114 --> 00:53:36.534 It's at the bottom, because when the sea language was invented machines did not have a lot of memory and compilers did not have enough memory to fit the whole program file and memory at 1 time. 369 00:53:36.954 --> 00:53:50.635 So they had the concept of past not just see for trend. And other languages, so compilers had this idea of making success of passes through the file because the computers did not have enough memory at that time. 370 00:53:50.940 --> 00:53:55.199 To store the whole program in memory at 1 time necessarily. 371 00:53:55.199 --> 00:53:59.429 At that time meeting, you know, 50, 60 years ago. 372 00:53:59.429 --> 00:54:12.269 Okay, and so if you're going to do that, then the main program would be at the bottom because they to compile the main program. They had to 1st know the functions that was calling. 373 00:54:12.269 --> 00:54:19.289 Okay, what's happening here? Excuse me? Um. 374 00:54:24.119 --> 00:54:28.559 We're clamping. 375 00:54:28.559 --> 00:54:35.579 So, input is a vector of data outputs. A factor of data clapped into a range. Okay. 376 00:54:35.579 --> 00:54:42.000 Meaning if an element smaller than the men that gets replaced by the men, bigger than the Max gets replaced by the max. 377 00:54:42.000 --> 00:54:46.139 Okay, how does it do this? 378 00:54:46.139 --> 00:54:58.260 This is going to be a 2 step process so make transform takes a vector of data here. 379 00:54:58.260 --> 00:55:04.289 And applies a unitary operator unitary function on each element of the data. 380 00:55:04.289 --> 00:55:08.820 So, clamp so values its pointing to. 381 00:55:08.820 --> 00:55:14.639 Data elements and clamp each element. Now, here's the thing. 382 00:55:14.639 --> 00:55:29.099 Make transform editor, it's like lazy evaluating. It does not return a transformed factor. It returns. And and if you should reference. 383 00:55:29.099 --> 00:55:35.610 You get the transformed value of the original element. So that's why there's no end here because this. 384 00:55:35.610 --> 00:55:39.809 Because the actual transformation process is done. 385 00:55:39.809 --> 00:55:44.400 A call is done when you de, reference a transformed. 386 00:55:45.114 --> 00:56:00.085 So you might think of just a pointer. Well, that's the simple version of an, these, when you do reference them, a function gets executed and what gets executed when you do reference incinerator is as follows. 387 00:56:00.630 --> 00:56:10.349 And because this, it takes some references, the corresponding to the data grabs the data element. 388 00:56:10.349 --> 00:56:16.380 Transforms it and returns a pointer to it and that's the return transform. 389 00:56:17.820 --> 00:56:23.400 So, this makes a at some. 390 00:56:23.400 --> 00:56:27.510 Complicated type that's not fit for human consumption, but. 391 00:56:28.739 --> 00:56:33.780 What is type? Actually, she clammed factor writer, which is defined up here. 392 00:56:33.780 --> 00:56:38.610 And notice that in terms of vector and everything. 393 00:56:38.610 --> 00:56:42.989 What do you do if you're going to do this? You say auto okay. 394 00:56:42.989 --> 00:56:49.380 Any case, so we make from the begin. 395 00:56:49.380 --> 00:56:53.909 And this is an integrator pointing to this virtual transformed vector. 396 00:56:53.909 --> 00:56:58.050 You add size to it, you get the end because you can always add. 397 00:56:58.050 --> 00:57:02.280 You know, in New Jersey too, you said 8 or so. Okay. So. 398 00:57:03.960 --> 00:57:10.170 You want to print to transform vex. So, what this does is it prints the transformed vector. 399 00:57:10.170 --> 00:57:16.679 It's never stored anywhere. You see, they're computed as print range. You reference. 400 00:57:16.679 --> 00:57:24.570 It's never stored anywhere. So, the interesting thing is to do the clamp. 401 00:57:26.219 --> 00:57:34.440 Um, okay, what is happening here? Okay, this is this is complicated mess, but. 402 00:57:34.440 --> 00:57:38.849 Very powerful clamp is a template to. 403 00:57:38.849 --> 00:57:42.119 Type or class plan and. 404 00:57:42.119 --> 00:57:45.630 That's the templated clamp. 405 00:57:45.630 --> 00:57:50.130 For camp specialized for. 406 00:57:50.130 --> 00:57:55.469 Okay, what we have here is a class name. 407 00:57:55.469 --> 00:58:00.420 A class, a type name, this constructs. 408 00:58:00.420 --> 00:58:03.960 A variable of class. 409 00:58:03.960 --> 00:58:11.730 Clamp and the constructor takes 2 arguments. So these are arguments to the type constructor. 410 00:58:11.730 --> 00:58:15.420 The output from here is. 411 00:58:15.420 --> 00:58:19.650 A variable of type clamp in. 412 00:58:21.269 --> 00:58:26.309 This variable surprise will has apprentice operator overloaded. 413 00:58:26.309 --> 00:58:31.289 Make transimitter, we'll take that variable call it as a function and transform. 414 00:58:34.079 --> 00:58:41.250 And because the compiler optimizes nicely, it does not go create constructing a separate variable every time. 415 00:58:41.250 --> 00:58:46.019 Make is called a constructs 1 and reuse it. 416 00:58:47.489 --> 00:58:57.000 Up here. Well, what's happening here? This is wrapping. 417 00:58:57.000 --> 00:59:02.159 Some simple function and it's overloading. 418 00:59:02.159 --> 00:59:05.460 Trust urinary function. 419 00:59:05.460 --> 00:59:11.519 It adds something to the semantics, but it's not very important if you didn't actually do that, you'd survive. 420 00:59:11.519 --> 00:59:17.039 Quite happily so this is the clamp class. 421 00:59:18.420 --> 00:59:21.630 And the default, and it has. 422 00:59:21.630 --> 00:59:27.269 Member data elements, low and high and the default constructor. 423 00:59:28.679 --> 00:59:34.920 This say it takes 2 arguments and says this is this notation where you Initialized. 424 00:59:34.920 --> 00:59:38.130 You can, you don't have to Initialized data. 425 00:59:38.130 --> 00:59:44.369 Member data elements in parallel and host device it's compiled for the host and the device. 426 00:59:44.369 --> 00:59:50.789 So, that's the constructor and this is overloading the so. 427 00:59:50.789 --> 00:59:55.500 And that's the big and again, you use a why? I'm doing now. 428 00:59:55.500 --> 00:59:58.500 For placeholder. 429 00:59:58.500 --> 01:00:06.840 Silence. 430 01:00:06.840 --> 01:00:16.380 I have clients that plant data. Okay. 431 01:00:16.380 --> 01:00:23.670 And just for fun, they indicated it didn't show you that code. Oh, okay. 432 01:00:25.679 --> 01:00:31.500 Transform. 433 01:00:31.500 --> 01:00:36.659 Trench for output to transform output. 434 01:00:37.679 --> 01:00:48.449 Okay, let me go down to the main here. Okay now, this is. 435 01:00:53.670 --> 01:01:03.659 What's going to happen? Here is transform output editor. It creates the as an L value. 436 01:01:04.195 --> 01:01:18.264 So and L value is a value you can write to and L value can appear on the left side of equals of assignment and our values a pure value can appear only on the right side. So, L, values are like, variables. 437 01:01:18.264 --> 01:01:19.465 You can write to them. 438 01:01:19.769 --> 01:01:29.670 So, we seen reading from fancy now we're going to see writing to a fancy editor, powerful idea. 439 01:01:36.360 --> 01:01:41.159 And there's a lot of stuff here in a small program. 440 01:01:43.289 --> 01:01:47.699 So, I may not give you the whole idea of it, but. 441 01:01:49.650 --> 01:01:54.150 We'll try you'll get a vague sense that it's interesting. 442 01:01:54.150 --> 01:02:01.889 Okay gather okay. So gather takes a list of indices. 443 01:02:06.090 --> 01:02:11.579 And, and basically goes into some data. 444 01:02:11.579 --> 01:02:16.170 And gathers Sadat, I gather, takes. 445 01:02:16.170 --> 01:02:27.510 Gather takes, it takes an input data vector and grabs elements from random places, input, data veteran, and puts them in order into an output data vector. 446 01:02:27.510 --> 01:02:30.750 So gathers elements for random places. 447 01:02:30.750 --> 01:02:34.289 So. 448 01:02:34.289 --> 01:02:42.030 And so what gather takes is these are the indices that we want of the data that we want. 449 01:02:42.030 --> 01:02:47.519 The 2nd, the 3rd argument is the data itself, it's an, to the data. 450 01:02:47.519 --> 01:02:52.170 And it's just so what we have is. 451 01:02:54.480 --> 01:02:58.530 Oh, we've got we've got use and v's up here. 452 01:03:02.820 --> 01:03:07.170 And. 453 01:03:07.170 --> 01:03:10.860 So you is just a 4 3 2 1. 454 01:03:10.860 --> 01:03:14.280 The V is minus 1 1, 1 minus 1. 455 01:03:14.280 --> 01:03:19.409 So, I don't know why their programming style here. 456 01:03:19.409 --> 01:03:24.449 This makes you think I could do so much better. I'm every weekend about my programming abilities. 457 01:03:24.449 --> 01:03:29.610 And I'm not, I'm not apologetic about it. I'm a good programmer. 458 01:03:29.610 --> 01:03:32.849 You won't believe how long I've been programming. 459 01:03:34.440 --> 01:03:41.130 Okay, so device factor, the use device vector as the V. 460 01:03:41.130 --> 01:03:51.179 It's a weird initialization thing I'd have to check the documentation myself. 461 01:03:51.179 --> 01:03:54.989 What's happening here? Essentially. 462 01:03:54.989 --> 01:03:58.650 If this flow, so this is a sample C style. 463 01:03:58.650 --> 01:04:08.130 Array so you considered by itself as a point, or 2 of these elements so this is initializing the device factor. 464 01:04:08.130 --> 01:04:11.789 Was basically a begin and an end pointer. 465 01:04:11.789 --> 01:04:15.239 Okay, so. 466 01:04:15.239 --> 01:04:20.369 So so what is happening here. 467 01:04:21.780 --> 01:04:29.070 Is it's making us which when you do reference it, you get of corresponding elements of you and V. 468 01:04:29.070 --> 01:04:33.269 This is the operator concept. Okay. So. 469 01:04:33.269 --> 01:04:39.360 So, the 1st element, zip Federated the 1st thing, you do reference it. You get a triple 4 and minus 1. 470 01:04:39.360 --> 01:04:44.519 You had 1 in D reference and you get a 2.3 and minus 1 and so on. 471 01:04:46.380 --> 01:04:51.750 Okay, so make, it's going to transform things. 472 01:04:51.750 --> 01:04:56.639 Um. 473 01:04:56.639 --> 01:05:03.090 And what does do okay. 474 01:05:03.090 --> 01:05:06.780 Naming something from its class that it is so totally weird. 475 01:05:06.780 --> 01:05:16.199 Okay, it takes it to Paul as it's 1 argument. So we're overloading CRNS. Now it takes a 2 pull as it's 1 argument. 476 01:05:18.449 --> 01:05:27.449 And takes his arrows element again and. 477 01:05:27.449 --> 01:05:33.119 The 1st element there, X and Y, and does some random silly computation. 478 01:05:33.119 --> 01:05:40.230 And returns it as a float, so. 479 01:05:42.960 --> 01:05:46.380 So, factor is just going to take. 480 01:05:46.380 --> 01:05:54.329 2 pulse and turn and do that computation on them. So where do we write the output into? 481 01:05:54.329 --> 01:05:59.789 We want to write the output into W here. 482 01:06:00.840 --> 01:06:06.179 And so we got a device sector, you. 483 01:06:06.179 --> 01:06:12.000 And. 484 01:06:12.000 --> 01:06:16.650 Okay, and I'm. 485 01:06:19.679 --> 01:06:24.539 And again, the last argument to gather is the iterate are saying. 486 01:06:25.889 --> 01:06:29.250 This, but what happens is that. 487 01:06:30.690 --> 01:06:36.599 We take an to, which is an Initialized array, and we are. 488 01:06:38.039 --> 01:06:42.719 Going to be transforming and writing to transformed elements of that. 489 01:06:42.719 --> 01:06:47.190 As I look at it now, I'm starting to confuse myself. Exactly. 490 01:06:47.190 --> 01:06:52.170 But the thing was to transform output. 491 01:06:54.300 --> 01:07:01.050 Is it returns in as an L value that you can write to, and gathers garner right? To. 492 01:07:01.050 --> 01:07:04.440 The output that gets returned by this. 493 01:07:04.440 --> 01:07:08.639 Let me try compiling it. 494 01:07:09.869 --> 01:07:14.010 Silence. 495 01:07:14.010 --> 01:07:21.420 So. 496 01:07:21.420 --> 01:07:26.610 The minus, so what happened was it didn't write the input again. 497 01:07:29.099 --> 01:07:34.619 Silence. 498 01:07:34.619 --> 01:07:39.420 So, what it did is it took corresponding elements here. 499 01:07:39.420 --> 01:07:50.190 Of this and of this. Okay. So what it did is, here's the output. Let me go the other. So I'll put the 1st out the 0 output element of Dolby, you. 500 01:07:50.190 --> 01:07:55.260 Is going to be gotten by processing the 3rd elements of you and V. 501 01:07:55.260 --> 01:08:02.730 Which are 1 and minus 1 it combines using the factor thing. 502 01:08:02.730 --> 01:08:07.260 Up here, so. 503 01:08:07.260 --> 01:08:12.090 And off the bottom again, just a 2nd. 504 01:08:14.610 --> 01:08:24.810 Yeah, so these so this element of diabetes is taken by combining a 3rd element of view in the and factor is how they're combined. 505 01:08:25.829 --> 01:08:35.489 That's the 1st, element of view is taken from the 0 elements of you, which are for and minus 1, combining them according to. 506 01:08:35.489 --> 01:08:41.039 The 2nd, element of is taken from the 1st element of view, and which is 3 and minus 1. 507 01:08:41.039 --> 01:08:46.920 Combining them, according to factor and all the work is done. 508 01:08:49.590 --> 01:08:54.239 And this thing here, so. 509 01:08:54.239 --> 01:08:59.939 Okay, and. 510 01:09:01.050 --> 01:09:05.609 So, again, gather says these are the. 511 01:09:07.829 --> 01:09:13.199 Which elements of the input data that we want to gather together. 512 01:09:13.199 --> 01:09:16.710 This is the input data. 513 01:09:16.710 --> 01:09:22.229 It's a virtual vector zipped up from you and V corresponding elements of you and me. 514 01:09:22.229 --> 01:09:25.409 And this is. 515 01:09:26.909 --> 01:09:33.989 Where are the output is going and it's a weird combo, make transforming output iterate or. 516 01:09:33.989 --> 01:09:39.630 I protect the data is. 517 01:09:39.630 --> 01:09:44.189 And starting a virtual pointer into up here. 518 01:09:44.189 --> 01:09:48.359 I know I left out a critical detail or 2, but. 519 01:09:48.359 --> 01:09:52.199 Okay, input, output iterate or. 520 01:10:00.689 --> 01:10:03.750 Dyslexic Co, graphic. 521 01:10:11.340 --> 01:10:15.119 I just did Alexa, go graph That'll come back to that. 522 01:10:18.180 --> 01:10:22.920 And so it will do electrical graphics sort and. 523 01:10:25.020 --> 01:10:35.965 So, what will happen is that we've got, we want to sort triples, sort 3 D points and extra graphic means. You sort on the 1st component is the 1st component there equally. 524 01:10:35.965 --> 01:10:48.564 Then you look at the 2nd, the secondary you look at the 3rd and the way you do it is your 1st, sort on the 3rd component, and then you stable start on the 2nd, and find these on the 1st and that does electrical graphics sort. 525 01:10:48.869 --> 01:10:53.279 Except what's happening here? 526 01:10:53.279 --> 01:10:56.550 The thing. 527 01:10:56.550 --> 01:11:08.579 Is going to use as sort function, which gives you a list of indices of the sorted factor. It doesn't permeate the factor. It gives you a list of permitted indices. 528 01:11:10.140 --> 01:11:14.399 And then at the end, we apply depart mutations. So. 529 01:11:15.689 --> 01:11:23.069 So, we're not moving the data around and this is good if, um. 530 01:11:23.069 --> 01:11:28.590 The dad is big, what's happening here? 531 01:11:28.590 --> 01:11:32.399 Silence. 532 01:11:32.399 --> 01:11:36.899 Silence. 533 01:11:36.899 --> 01:11:40.409 Silence. 534 01:11:40.409 --> 01:11:43.470 Silence. 535 01:11:43.470 --> 01:11:49.439 Random keys and they're sorted by 1st component then 2nd and 3rd. 536 01:11:49.439 --> 01:11:53.100 And again the. 537 01:11:53.100 --> 01:11:58.260 Something that's worth remembering about this, is that. 538 01:11:58.260 --> 01:12:04.920 We're playing with the permeated vectors of permitted vectors of indices. 539 01:12:07.409 --> 01:12:14.310 And it's a stable sort, which takes the data, but doesn't change the data. 540 01:12:14.310 --> 01:12:17.970 8 updates a permutation actor, so. 541 01:12:19.619 --> 01:12:24.359 And then the gather applies the permutation vector. So. 542 01:12:28.170 --> 01:12:32.699 Yeah, and. 543 01:12:38.279 --> 01:12:42.180 And here are the 3 sorts update permutation and. 544 01:12:42.180 --> 01:12:45.659 Okay, so, um. 545 01:12:45.659 --> 01:12:52.949 Update permutation does a sort of permutation and. 546 01:12:56.159 --> 01:13:01.260 It's playing with permutations index sectors, so. 547 01:13:02.760 --> 01:13:06.659 Okay, input output. 548 01:13:07.859 --> 01:13:11.789 Silence. 549 01:13:11.789 --> 01:13:15.840 Okay, um. 550 01:13:15.840 --> 01:13:20.939 So, this is just getting crazier with. 551 01:13:23.100 --> 01:13:26.909 And so. 552 01:13:29.010 --> 01:13:34.560 So transform input output that could be an L value or in our value. 553 01:13:34.560 --> 01:13:38.100 And to. 554 01:13:38.100 --> 01:13:47.760 And I'll just give you a high level thing and this is that these output and input they're use I've used them in some of my own research. 555 01:13:47.760 --> 01:13:51.060 It's nice to be able to. 556 01:13:51.060 --> 01:13:56.010 To work with these crazier and crazier. 557 01:13:56.010 --> 01:14:03.449 So, in any case. 558 01:14:05.489 --> 01:14:09.029 Again, I'm. 559 01:14:10.140 --> 01:14:16.020 It just takes it takes an underwriter and so we have our data a here. 560 01:14:16.020 --> 01:14:21.359 And the doc began, it's just a more intelligent and then. 561 01:14:21.359 --> 01:14:29.250 I'm just waiting my hands a little I want to leave you with the concept that it is. 562 01:14:29.250 --> 01:14:35.010 Powerful and what it is, we can read and write. We have a vector. 563 01:14:35.010 --> 01:14:43.229 And we can read and write scaled versions of the entertainers and that's sort of create if you write the scale version, it unscaled that. 564 01:14:43.229 --> 01:14:47.189 It scales it back and unscaled and so. 565 01:14:47.189 --> 01:14:53.010 We have the original data, and then we can read and write scaled versions of the data. 566 01:14:53.010 --> 01:14:58.199 Without storing an extra sort of hokey, but it's fun. Um, let me. 567 01:14:59.579 --> 01:15:03.569 Try it. 568 01:15:06.720 --> 01:15:10.920 Silence. 569 01:15:12.210 --> 01:15:18.840 Well, we'd have to look at the code, so that's basically there's other crazy things in here. 570 01:15:18.840 --> 01:15:22.170 But the concept is. 571 01:15:22.170 --> 01:15:27.060 With the segmented scans and segmented reductions and so on. 572 01:15:27.060 --> 01:15:32.010 The only 1 data type, the vector. 573 01:15:32.010 --> 01:15:35.250 It can be incredibly powerful and it works. 574 01:15:35.250 --> 01:15:40.350 It works in parallel, so those are the big examples here. 575 01:15:40.350 --> 01:15:45.210 So. 576 01:15:45.210 --> 01:15:49.949 Good point to stop. We spend 2 weeks on. It's well worth it. 577 01:15:49.949 --> 01:16:02.640 Trust back ends. Okay some stuff I haven't done is the latest version of thrust. You don't have to be so specific about hosts versus device. 578 01:16:02.640 --> 01:16:07.680 It has so it can, um, work with the unified addressing. 579 01:16:09.239 --> 01:16:13.979 But you can be specific about thrust back and. 580 01:16:13.979 --> 01:16:23.250 And you can specify the back end at compile time, or you can specify as another argument in the functions. So the back end could be just a simple. 581 01:16:24.024 --> 01:16:38.064 Sequential program it could be on Intel. It could be threading building blocks. It is an Intel proprietary analog to open MP. It could be open. Mpc. You can use the multi core, or it could be CUDA to run on video. 582 01:16:40.649 --> 01:16:46.529 And you can, and you can tell that compile time, which it should dispatch to. 583 01:16:46.529 --> 01:16:50.039 This I think I might have to update. 584 01:16:51.119 --> 01:17:05.850 Oh, it has it here. Yeah. And video went and move stuff around. They didn't update all their point is correctly. But so this is this is not showing you something useful, but at compile time, you can specify what the code should be compiled for. 585 01:17:07.170 --> 01:17:11.460 And I talked about this before it's some low level. 586 01:17:11.460 --> 01:17:16.529 Operating system support for this unified ad dressing so. 587 01:17:16.529 --> 01:17:27.300 I don't know if her operating system courses necessarily get into modern stuff like that. So this is quite a detail. So if you're into operating system, it is quite a detailed description of what's happening. 588 01:17:27.300 --> 01:17:32.039 Okay, so what happens next, which is Monday because remember Thursday is. 589 01:17:32.039 --> 01:17:35.069 Wellness day. 590 01:17:36.479 --> 01:17:40.020 So, take a break. 591 01:17:40.020 --> 01:17:43.470 We know, I just decided like, 2 weeks ago to do this. 592 01:17:43.470 --> 01:17:47.640 So, take a break go hi. Can get some physical exercise. 593 01:17:47.640 --> 01:17:52.710 And if you want to read ahead, so for quantum computing. 594 01:17:52.710 --> 01:18:01.710 Just for a minute or 2, I created a quantum computing summary. So I started actually 2 years ago putting a quantum computing module in this course. 595 01:18:01.710 --> 01:18:07.859 And then I expanded it to a full separate course that I teach in the fall term on quantum computing. 596 01:18:07.859 --> 01:18:12.779 And you can go and look at it here and quantum computer programming. 597 01:18:12.779 --> 01:18:16.890 I named it that. 598 01:18:16.890 --> 01:18:28.979 To be distinguished from, say, quantum computing physics and so on, in any case, I have a summary here that I've given to various people around and. 599 01:18:28.979 --> 01:18:39.359 What I'll start by is going through this summary of quantum computing, quantum computer programming and then I'll spend, I guess, the rest of the semester expanding on it and. 600 01:18:39.359 --> 01:18:44.069 Give you how many weeks you've got laptop lost count. 601 01:18:44.069 --> 01:18:49.409 Giving you a quantum computing in more detail, including. 602 01:18:49.409 --> 01:18:57.869 Some points are IBM as a free quantum computers online. They also have a simulator. There's several competing. 603 01:18:57.869 --> 01:19:05.579 Hardware realizations track, ions, quantum annealing and Google. 604 01:19:05.579 --> 01:19:12.090 Amazon, I'm sorry in Microsoft have machines like Amazon, elastic compute cluster and so on. 605 01:19:12.090 --> 01:19:17.520 And you can use these machines for chriser free or a small amount of money. 606 01:19:17.520 --> 01:19:25.800 So That'll be next week. Oh, okay. I may say, can you pass it a function to term duplicates? 607 01:19:25.800 --> 01:19:40.770 Well, yeah, I mean about this is looking for starts of each runs. Yeah, you can pass it a function. Yeah. The reduced thing you use. 608 01:19:40.770 --> 01:19:49.260 Well, to determine duplicates is determining if 2 elements are the same and this is. 609 01:19:50.729 --> 01:19:54.689 Yeah, you're right, it was placeholder on rotation underscore 1. 610 01:19:54.689 --> 01:19:58.649 Not equal underscore to possibly work, but we can try it. If you. 611 01:19:58.649 --> 01:20:06.329 The default operator for reduces multiply. So you maybe don't want that. 612 01:20:07.979 --> 01:20:16.649 Is our value is values modified. Okay. That's a deep and confusing question. I'm looking at the question. 613 01:20:16.649 --> 01:20:20.729 From Isaac is values modified when the underwriter is referenced. 614 01:20:20.729 --> 01:20:25.050 You can reference it and assigned to it. 615 01:20:25.050 --> 01:20:29.789 So you can say star pointer equals flu. 616 01:20:29.789 --> 01:20:33.810 And now food got written into. 617 01:20:33.810 --> 01:20:41.340 Thing, so this is, if it's an output iterate, or you can write to it, and you can update the factor. 618 01:20:41.340 --> 01:20:45.479 Now, you've hit on something Isaac there. 619 01:20:45.479 --> 01:20:48.779 Which is actually not documented. 620 01:20:48.779 --> 01:20:58.590 Cleanly and I know that, because I've tried to understand it myself to use in my own to use in my own programming. So. 621 01:20:58.590 --> 01:21:01.770 Yeah, you hit on a deep topic there, but. 622 01:21:01.770 --> 01:21:09.180 It transform it input output or anything. Well, sort of I know those functions. Those programs are documented that. Well. 623 01:21:09.180 --> 01:21:14.279 Maybe I might even maybe next time then do a simple example of that. 624 01:21:14.279 --> 01:21:17.369 At this start upon them could be because it's a powerful idea. 625 01:21:17.369 --> 01:21:22.590 At least I'm biased I think it's powerful because I've had I wanted to use it, so. 626 01:21:23.819 --> 01:21:27.449 Anything else if not. 627 01:21:27.449 --> 01:21:32.880 I have a good week, lunch time and see, you. 628 01:21:35.760 --> 01:21:47.939 Next Monday oh, 1 more question before I go. So, by writing over 1 of the output iterate is multiple input values. 629 01:21:47.939 --> 01:21:55.109 You want to be careful something like scatter. 630 01:21:55.109 --> 01:21:59.909 You don't want to have 2 different elements being written to the same place because then we've got. 631 01:21:59.909 --> 01:22:09.270 Whose 1st issue, so but in parallel, lots of things could be changed. 632 01:22:09.270 --> 01:22:13.890 Um, so. 633 01:22:13.890 --> 01:22:18.989 This transcript thing is worth saving, so, um. 634 01:22:18.989 --> 01:22:23.819 Let me just save it before I end. 635 01:22:23.819 --> 01:22:29.699 And maybe, like I said, you hit on something. 636 01:22:29.699 --> 01:22:33.060 Complicated. 637 01:22:33.060 --> 01:22:37.949 Yeah. 638 01:22:37.949 --> 01:22:42.210 Okay, if nothing else bye.