PAR Class 17, Thurs 2021-03-25
Table of contents
1 Student talks
Connor. cloud-based/docker-base parallel computing.
Isaac. Aerospace.
Jack. Nvidia's autonomous machines.
2 Several forms of C++ functions
-
Traditional top level function
auto add(int a, int b) { return a+b;}
You can pass this to a function. This really passes a pointer to the function. It doesn't optimize across the call.
-
Overload operator() in a new class
Each different variable of the class is a different function. The function can use the variable's value. This is a closure.
This is local to the containing block.
This form optimizes well.
-
Lambda, or anon function.
auto add = [](int a, int b) { return a+b;};
This is local to the containing block.
This form optimizes well.
-
Placeholder notation.
As an argument in, e.g., transform, you can do this:
transform(..., _1+_2);
This is nice and short.
As this is implemented by overloading the operators, the syntax of the expression is limited to what was overloaded.
3 Thrust
Thrust is an API that looks like STL. Its backend can be GPU-CUDA, OpenMP, TBB, or sequential host-based code.
Functional-programming philosophy.
Easier programming, once you get used to it.
Code is efficient.
Uses some unusual C++ techniques, like overloading operator().
Since the Stanford slides were created, Thrust has adopted unified addressing, so that pointers know whether they are host or device.
We'll start lecture 8, which has a lot of content. Today we did up thru slide 24.