Skip to main content

PAR Class 26, Mon 2020-04-27

1   Final project presentations

  1. Joe C & Alex Z
  2. Mike M
  3. Matt R & Skyl S
  4. Eliz C
  5. John F & Hayl R & Mish S
  6. Ross D
  7. Clar S & Garr D
  8. Liz C
  9. Zhep L

2   Final project and prior work

If your final project is building on, or sharing with, another course or project (say on GitHub), then you must give the details, and say what's new for this course.

3   After the semester

I'm open to questions and discussions about any legal ethical topic. Even after you graduate.

PAR Class 25, Thurs 2020-04-23

1   Final paper format

Try to use the IEEE conference format . It allows either latex or MS word. Submit the PDF paper to gradescope.

2   Final project presentations

  1. Kevi M
  2. Liz C
  3. Chri H
  4. Zhep L

3   Inspiration for finishing your term projects

  1. The Underhanded C Contest

    "The goal of the contest is to write code that is as readable, clear, innocent and straightforward as possible, and yet it must fail to perform at its apparent function. To be more specific, it should do something subtly evil. Every year, we will propose a challenge to coders to solve a simple data processing problem, but with covert malicious behavior. Examples include miscounting votes, shaving money from financial transactions, or leaking information to an eavesdropper. The main goal, however, is to write source code that easily passes visual inspection by other programmers."

  2. The International Obfuscated C Code Contest

  3. https://www.awesomestories.com/asset/view/Space-Race-American-Rocket-Failures

    Moral: After early disasters, sometimes you can eventually get things to work.

  4. The 'Wrong' Brothers Aviation's Failures (1920s)

  5. Early U.S. rocket and space launch failures and explosion

  6. Numerous US Launch Failures

4   Software tips

4.1   Git

Git is good to simultaneously keep various versions. Here's a git intro:

Create a dir for the project:

mkdir PROJECT; cd PROJECT

Initialize:

git init

Create a branch (you can do this several times):

git branch MYBRANCHNAME

Go to a branch:

git checkout MYBRANCHNAME

Do things:

vi, make, ....

Save it:

git add .; git commit -mCOMMENT

Repeat

At times I've used this to modify a program for class while keeping a copy of the original.

4.2   Freeze decisions early: SW design paradigm

One of my rules is to push design decisions to take effect as early in the process execution as possible. Constructing variables at compile time is best, at function call time is 2nd, and on the heap is worst.

  1. If I have to construct variables on the heap, I construct few and large variables, never many small ones.

  2. Often I compile the max dataset size into the program, which permits constructing the arrays at compile time. Recompiling for a larger dataset is quick (unless you're using CUDA).

    Accessing this type of variable uses one less level of pointer than accessing a variable on the heap. I don't know whether this is faster with a good optimizing compiler, but it's probably not slower.

  3. If the data will require a dataset with unpredictably sized components, such as a ragged array, then I may do the following.

    1. Read the data once to accumulate the necessary statistics.
    2. Construct the required ragged array.
    3. Reread the data and populate the array.

Update: However, with CUDA, maybe managed variables must be on the heap.

5   CPPCON

CppCon is the annual, week-long face-to-face gathering for the entire C++ community. https://cppcon.org/

https://cppcon2018.sched.com/

CppCon 2014: Herb Sutter "Paying for Lunch: C++ in the ManyCore Age" https://www.youtube.com/watch?v=AfI_0GzLWQ8

CppCon 2016: Combine Lambdas and weak_ptrs to make concurrency easy (4min) https://www.youtube.com/watch?v=fEnnmpdZllQ

A Pragmatic Introduction to Multicore Synchronization by Samy Al Bahra. https://www.youtube.com/watch?v=LX4ugnzwggg

CppCon 2018: Tsung-Wei Huang “Fast Parallel Programming using Modern C++” https://www.youtube.com/watch?v=ho9bqIJkvkc&list=PLHTh1InhhwT7GoW7bjOEe2EjyOTkm6Mgd&index=13

CppCon 2018: Anny Gakhokidze “Workflow hacks for developers” https://www.youtube.com/watch?v=K4XxeB1Duyo&list=PLHTh1InhhwT7GoW7bjOEe2EjyOTkm6Mgd&index=33

CppCon 2018: Bjarne Stroustrup “Concepts: The Future of Generic Programming (the future is here)” https://www.youtube.com/watch?v=HddFGPTAmtU

CppCon 2018: Herb Sutter “Thoughts on a more powerful and simpler C++ (5 of N)” https://www.youtube.com/watch?v=80BZxujhY38

CppCon 2018: Jefferson Amstutz “Compute More in Less Time Using C++ Simd Wrapper Libraries” https://www.youtube.com/watch?v=80BZxujhY38

CppCon 2018: Geoffrey Romer “What do you mean "thread-safe"?” https://www.youtube.com/watch?v=s5PCh_FaMfM

7   Supercomputing 2018 (SC18) videos

SC18 Invited Talk: Matthias Troyer https://www.youtube.com/watch?v=97s3FEhG14g (45:46)

This is very nice. I'll show the start and then a highlight, starting at 19:00.

SC18: NVIDIA CEO Jensen Huang on the New HPC (1:44:46) https://www.youtube.com/watch?v=PQbhxfRH2H4

We'll watch the wrapup,

SCinet Must See: How to Build the World’s Fastest Temporary Computer Network Time Lapse (0:57) https://sc18.supercomputing.org/scinet-must-see-how-to-build-the-worlds-fastest-temporary-computer-network-time-lapse/

8   Jack Dongarra

He has visited RPI more than once.

Algorithms for future emerging technologies (2:55:45) https://www.youtube.com/watch?v=TCgHNMezmZ8

We'll watch the start. You're encouraged to watch it all. It gets more technical later.

Stony Brook talk https://www.youtube.com/watch?v=D1hfrtoVZDo

9   Course survey

I see my role as a curator, selecting the best stuff to present to you. Since I like the topic, and asked to be given permission to create this course, I pick things I like since you might like them too.

So, if you liked the course, then please officially tell RPI by completing the survey and saying what you think. Thanks.

PAR Class 24, Mon 2020-04-20

1   Exascale computing

https://www.nextplatform.com/2019/12/04/openacc-cozies-up-to-c-c-and-fortran-standards/

https://www.nextplatform.com/2019/01/09/two-thirds-of-the-way-home-with-exascale-programming/

They agree with me that fewer bigger parallel processors are better than many smaller processors connected with MPI. I.e., they like my priorities in this course.

2   Final project presentation

Sava C & Davi P & Emil V

3   Quantum computing ctd: Shor's algorithm

  1. Factorize an int.
  2. in BQP.
  3. almost exponentially faster than best classical algorithm.
  4. When I searched for the largest example, I found several inconsistent announcements in the last year or two.
    1. 1005973. There is some disagreement about D-wave machines.
    2. 21
    3. 35
    4. 56153 = 233 × 241.
    5. https://medium.com/@aditya.yadav/rsa-2048-cracked-using-shors-algorithm-on-a-quantum-computer-660cb2297a95
  5. Interesting about factoring:
    1. https://arstechnica.com/information-technology/2019/12/new-crypto-cracking-record-reached-with-less-help-than-usual-from-moores-law/
    2. https://www.schneier.com/blog/archives/2019/10/factoring_2048-.html
    3. https://www.quintessencelabs.com/blog/breaking-rsa-encryption-update-state-art/

3.1   Youtube

27 Quantum Mechanics - Measurement 8:07

Shor on, what is Shor's factoring algorithm? (2:09) https://www.youtube.com/watch?v=hOlOY7NyMfs

Hacking at Quantum Speed with Shor's Algorithm (16:35) https://www.pbs.org/video/hacking-at-quantum-speed-with-shors-algorithm-8jrjkq/

43 Quantum Mechanics - Quantum factoring Period finding (19:27) https://www.youtube.com/watch?v=crMM0tCboZU

44 Quantum Mechanics - Quantum factoring Shor's factoring algorithm (25:42) https://www.youtube.com/watch?v=YhjKWAMFBUU

PAR Class 23, Thurs 2020-04-16

1   Final projects

1.1   Presentations

  1. Mon April 20
    1. Sava C & Davi P & Emil V
  2. Thurs April 23
    1. Kevi M
    2. Liz C
    3. Chri H
    4. Zhep L
  3. Mon April 27
    1. Joe C & Alex Z
    2. Mike M
    3. Matt R & Skyl S
    4. Eliz C
    5. John F & Hayl R & Mish S
    6. Ross D
    7. Clar S & Garr D

1.2   Reports

Due last class day, Wed April 29.

See syllabus.

To the 2 students in the grad version: do more work.

2   Quantum computing ctd

2.1   Grover's algorithm etc

  1. Algorithms:
    1. Some, but not all, are faster.
    2. Bounded-error quantum polynomial time (BQP)
      1. "is the class of decision problems solvable by a quantum computer in polynomial time, with an error probability of at most 1/3 for all instances" - https://en.wikipedia.org/wiki/BQP
      2. Includes integer factorization and discrete log.
      3. Relation to NP is unknown (big unsolved problem).
    3. Grover's algorithm:
      1. https://en.wikipedia.org/wiki/Grover%27s_algorithm
      2. Given a black box with N inputs and 1 output.
      3. Exactly one input makes the output 1.
      4. Problem: which one?
      5. Classical solution: Try each input, T=N.
      6. Quantum: $T=\sqrt(N)$.
      7. Probabilistic.
      8. Apps: mean, median, reverse a crypto hash, find collisions, generate false blocks.
      9. Can extend to quantum partial search.
      10. Grover's algorithm is optimal.
      11. This suggests that NP is not in BQP .

PAR Class 22, Mon 2020-04-13

1   Final project presentations

Anyone who did not sign up is signed up for Thurs April 23.

2   parallel.ecse status

I had to reinstall linux and the packages. If something is missing, please tell me. /opt, /local and your accounts should be the same. Cuda is now up to version 10.2.

The problem was a failed update that resulted in the boot image being damaged.

PAR Class 21, Thu 2020-04-09

1   Final project presentations

Remember to sign up.

2   Thrust

  1. The Thrust examples teach several non-intuitive paradigms. As I figure them out, I'll describe a few. My descriptions are modified and expanded versions of the comments in the programs. This is not a list of all the useful programs, but only of some where I am adding to their comments.

    1. arbitrary_transformation.cu and dot_products_with_zip.cu. show the very useful zip_iterator. Using it is a 2-step process.

      1. Combine the separate iterators into a tuple.
      2. Construct a zip iterator from the tuple.

      Note that operator() is now a template.

    2. boundingbox.cu finds the bounding box around a set of 2D points.

      The main idea is to do a reduce. However, the combining operation, instead of addition, is to combine two bounding boxes to find the box around them.

      The combining op can be any associative op.

    3. bucket_sort2d.cu overlays a grid on a set of 2D points and finds the points in each grid cell (bucket).

      1. The tuple is an efficient class for a short vector of fixed length.

      2. Note how random numbers are generated. You combine an engine that produces random output with a distribution.

        However you might need more complicated coding to make the numbers good when executing in parallel. See monte_carlo_disjoint_sequences.cu.

      3. The problem is that the number of points in each cell is unpredictable.

      4. The cell containing each point is computed and that and the points are sorted to bring together the points in each cell.

      5. Then lower_bound and upper_bound are used to find each bucket in that sorted vector of points.

      6. See this lower_bound description.

    4. mode.cu shows:

      1. Counting the number of unique keys in a vector.
        1. Sort the vector.
        2. Do an inner_product. However, instead of the operators being times and plus, they are not equal to the next element and plus.
      2. Counting their multiplicity.
        1. Construct vectors, sized at the number of unique keys, to hold the unique keys and counts.
        2. Do a reduce_by_keys on a constant_iterator using the sorted vector as the keys. For each range of identical keys, it sums the constant_iterator. That is, it counts the number of identical keys.
        3. Write a vector of unique keys and a vector of the counts.
      3. Finding the most used key (the mode).
        1. Do max_element on the counts vector.
    5. repeated_range.cu repeats each element of an N-vector K times: repeated_range([0, 1, 2, 3], 2) -> [0, 0, 1, 1, 2, 2, 3, 3]. It's a lite version of expand.cu, but uses a different technique.

      1. Here, N=4 and K=2.
      2. The idea is to construct a new iterator, repeated_range, that, when read and incremented, will return the proper output elements.
      3. The construction stores the relevant info in structure components of the variable.
      4. Treating its value like a subscript in the range [0,N*K), it divides that value by K and returns that element of its input.

      See also strided_range.cu and tiled_range.cu.

2.1   Backends

  1. The Thrust device can be CUDA, OpenMP, TBB, etc.

  2. You can spec it in 2 ways:

    1. by adding an extra arg at the start of a function's arg list.

    2. with an envar

      https://github.com/thrust/thrust/wiki/Host-Backends

      https://github.com/thrust/thrust/wiki/Device-Backends

PAR Class 20, Mon 2020-04-06

1   Final project presentations

  1. 12 minute presentations.
  2. Do on last 3 classes, Mon Apr 20, Thurs 23, Mon 27.
  3. Up to 7 a class; FCFS.
  4. Sign up on doodle; I sent everyone invitations.

2   Thrust ctd

2.1   Alternate docs in /parallel-class/thrust/doc/

  1. GTC_2010_Part_2_Thrust_By_Example.pdf

    Start at slide 27.

2.2   Examples

The point of these examples is to show you some techniques for parallel programming that are not obvious. I.e., you probably wouldn't think of them if you did not already know them.

  1. I rewrote /parallel-class/thrust/examples-1.8/tiled_range.cu into /parallel-class/thrust/rpi/tiled_range2.cu .

    It is now much shorter and much clearer. All the work is done here: ..

    gather(make_transform_iterator(make_counting_iterator(0), _1%N), make_transform_iterator(make_counting_iterator(N*C), _1%N), data.begin(), V.begin());

    1. make_counting_iterator(0) returns pointers to the sequence 0, 1, 2, ...
    2. _1%N is a function computing modulo N.
    3. make_transform_iterator(make_counting_iterator(0), _1%N) returns pointers to the sequence 0%N, 1%N, ...
    4. gather populates V. The i-th element of V gets make_transform_iterator...+i element of data, i.e., the i%N-th element of data.
  2. tiled_range3.cu is even shorter. Instead of writing an output vector, it constructs an iterator for a virtual output vector: ..

    auto output=make_permutation_iterator(data, make_transform_iterator(make_counting_iterator(0), _1%N));

    1. *(output+i) is *(data+(i%N)).
    2. You can get as many tiles as you want by iterating.
    3. tiled_range3.cu also constructs an iterator for a virtual input vector (in this case a vector of squares) instead of storing the data:

    auto data = make_transform_iterator(make_counting_iterator(0), _1*_1);

  3. tiled_range5.cu shows how to use a lambda instead of the _1 notation:

    auto output=make_permutation_iterator(data, make_transform_iterator(make_counting_iterator(0), [](const int i){return i%N;} ));

    1. You have to compile with --std c++11 .

    2. This can be rewritten thus: ..

      auto f = [](const int i){return i%N;}; auto output = make_permutation_iterator(data, make_transform_iterator(make_counting_iterator(0), f));

    3. The shortest lambda is this:

      auto f = [](){};

  4. repeated_range2.cu is my improvement on repeated_range.cu: ..

    auto output=make_permutation_iterator(data.begin(), make_transform_iterator(make_counting_iterator(0), _1/3));

    1. make_transform_iterator(make_counting_iterator(0), _1/3)) returns pointers to the sequence 0,0,0,1,1,1,2,2,2, ...
  5. Unmodified thrust examples:

    1. expand.cu takes a vector like V= [0, 10, 20, 30, 40] and a vector of repetition counts, like C= [2, 1, 0, 3, 1]. Expand repeats each element of V the appropriate number of times, giving [0, 0, 10, 30, 30, 30, 40]. The process is as follows.

      1. Since the output vector will be longer than the input, the main program computes the output size, by reduce summing C, and constructs a vector to hold the output.
      2. Exclusive_scan C to obtain output offsets for each input element: C2 = [0, 2, 3, 3, 6].
      3. Scatter_if the nonzero counts into their corresponding output positions. A counting iterator, [0, 1, 2, 3, 4] is mapped with C2, using C as the stencil, giving C3 = [0, 0, 1, 3, 0, 0, 4].
      4. An inclusive_scan with max fills in the holes in C3, to give C4 = [0, 0, 1, 3, 3, 3, 4].
      5. Gather uses C4 to gather elements of V: [0, 0, 10, 30, 30, 30, 40].
    2. set_operations.cu. This shows methods of handling an operation whose output is of unpredictable size. The question is, is space or time more important?

      1. If the maximum possible output size is reasonable, then construct an output vector of that size, use it, and then erase it down to its actual size.

      2. Or, run the operation twice. The 1st time, write to a discard_iterator, and remember only the size of the written data. Then, construct an output vector of exactly the right size, and run the operation again.

        I use this technique a lot with ragged arrays in sequential programs.

    3. sparse_vector.cu represents and sums sparse vectors.

      1. A sparse vector has mostly 0s.

      2. The representation is a vector of element indices and another vector of values.

      3. Adding two sparse vectors goes as follows.

        1. Allocate temporary index and element vectors of the max possible size (the sum of the sizes of the two inputs).

        2. Catenate the input vectors.

        3. Sort by index.

        4. Find the number of unique indices by applying inner_product with addition and not-equal-to-next-element to the indices, then adding one.

          E.g., applied to these indices: [0, 3, 3, 4, 5, 5, 5, 8], it gives 5.

        5. Allocate exactly enough space for the output.

        6. Apply reduce_by_key to the indices and elements to add elements with the same keys.

          The size of the output is the number of unique keys.

  6. What's the best way to sort 16000 sets of 1000 numbers each? E.g., sort the rows of a 16000x1000 array? On geoxeon, /pc/thrust/rpi/comparesorts.cu, which I copied from http://stackoverflow.com/questions/28150098/how-to-use-thrust-to-sort-the-rows-of-a-matrix|stackoverflow, compares three methods.

  7. Call the thrust sort 16000 times, once per set. That took 10 secs.

  8. Sort the whole list of 16,000,000 numbers together. Then sort it again by key, with the keys being the set number, to bring the elements of each set together. Since the sort is stable, this maintains the order within each set. (This is also how radix sort works.) That took 0.04 secs.

  9. Call a thrust function (to sort a set) within another thrust function (that applies to each set). This is new in Thrust 1.8. That took 0.3 secs.

This is a surprising and useful paradigm. It works because

  1. There's an overhead to starting each thrust function, and
  2. Radix sort, which thrust uses for ints, takes linear time.

PAR quantum intro, Wed 2020-03-25

2   Viewpoint of this presentation

  1. I don't care how qbits are implemented. That's important, even necessary, but it's someone else's problem.

  2. This recapitulates the development of quantum computing, where the theory was worked out starting in the 1980s, long before actual quantum computers were built.

    (Analogously, the theory for classical computers was worked out in the 1930s, long before real computers were built. Alan Turing contributed to both the theory and the practice.)

  3. This presentation may have many errors, but I hope that the general tenor is not too misleading.

3   Entanglement

warmup

Classical metaphor for entanglement:

  1. Start with a piece of paper.
  2. Tear it into two halves.
  3. Put each half into an envelope, seal them, and mix them up, so that you can't tell which half is in which envelope.
  4. Address and mail one envelope to a friend in Australia, and the other to a friend in Greenland.
  5. When the Australian opens his envelope, he knows what the Greenlander will find in his.
  6. However that doesn't let the Australian send any info to the Greenlander, or vv.
  7. This has been demonstrated with real qbits transported 1000 miles apart.

Technical details later.

4   Classical computation

  1. Bit.
  2. Its 2 possible values are 0 or 1.
  3. Byte.
  4. Has 8 bits.
  5. It has 256 possible values.
  6. Bits are transformed with gates, like nand, nor, and, or, xor, not, ...
  7. They generally destroy info, and are not invertible.
  8. More complex circuits, like adders, are formed from a combo of these gates.

5   Quantum computation

  1. Qbit, $q$.

  2. Its state is a linear combo of two basis states, $|0>$ and $|1>$:

    $q = a|0> + b|1>$ ,

    where $a$ and $b$ are complex numbers, and $ | a | ^2 + | b | ^2 = 1$.

  3. IOW, its state is a superposition of those two basis states, with those weights.

  4. It is wrong to think that $q$ is really in one of the two states, but you don't know which one. This is the hidden variable theory. It has been proved experimentally to be false.

  5. $q$ is really in both states simultaneously.

    Alice laughed. "There's no use trying," she said: "one can't believe impossible things." "I daresay you haven't had much practice," said the Queen. "When I was your age, I always did it for half-an-hour a day. Why, sometimes I've believed as many as six impossible things before breakfast." - Through the Looking-Glass, and What Alice Found There (1871), by Lewis Carroll (Charles Lutwidge Dodgson).

  6. You cannot observe its state, unless it is $|0>$ and $|1>$, in which case you observe $0$ or $1$. This is the classical case.

  7. Otherwise you observe it with a measurement operator that transforms it to either $|0>$ and $|1>$, with probabilities

    $| a | ^2$ and $| b | ^2 = 1$, respectively.

  8. $a$ and $b$ are complex.

  9. That measurement changes $q$; it no longer has its old value.

  10. $q$, that is, $q$ 's value, can be considered to be a vector of length one: $$\begin{pmatrix} a | 0> \\ b | 1> \end{pmatrix} $$ or simply $$\begin{pmatrix}a\\b\end{pmatrix}$$.

  11. You operate on $q$ with a matrix multiplication: $q_2 = M q$.

  12. This changes $q$; the old value is no longer available.

  13. No cloning: You cannot copy a qbit, but can move it.

  14. The life cycle of a qbit:

    1. Create a qbit with a classical value, 0 or 1.
    2. Operate on it with matrices, which rotate it to have complex weights.
    3. Transform it back to 0 or 1 and read it.
  15. So far, not very powerful.

  16. Now, let $q$ be a system with two qbits, i.e., a 2-vector of qbits.

  17. $q$ is now a linear combo of 4 basis values, $ | 00>$, $ | 01>$, $ | 10>$, $ | 11>$.

  18. $q = a_0 | 00> + a_1 | 01> + a_2 | 10> + a_3 | 11> $

  19. where $a_i$ are complex and $ \sum | a_i | ^2 = 1$.

  20. $q$ exists in all 4 states simultaneously.

  21. If $q$ is a vector with n component qbits, then it exists in $2^n$ states simultaneously.

  22. This is part of the reason that quantum computation is powerful.

  23. Measuring $q$ will collapse it to one of {00, 01, 10, 11} with probabilities $ | a_i | ^2$.

  24. You operate on $q$ by multiplying it by a 4x4 matrix operator.

  25. The matrices are all invertible, and all leave $ | q | = 1$.

  26. You set the initial value of $q$ by setting its two qbits each to 0 or 1.

  27. How this is done depends on the particular hw.

  28. I.e., initially, $q_1 = \begin{pmatrix}a_1 | 0> \\b_1 | 1> \end{pmatrix}$ and $q_2 = \begin{pmatrix}a_2 | 0> \\b_2 | 1> \end{pmatrix}$, and so

    $$q = \begin{pmatrix} q_1 \\ q_2 \end{pmatrix} = \begin{pmatrix} a_1 a_2 | 00 > \\ a_1 b_2 | 01 > \\ a_2 b_1 | 10 > \\ b_1 b_2 | 11 > \end{pmatrix}$$.

  29. Here, the combined state is the tensor product of the individual qbits.

  30. For $n$ qbits, the tensor product is a vector with $2^n$ elements, one element for each possible value of each qbit.

  31. Each element of the tensor product has a complex weight.

  32. You transform a state by multiplying it by a matrix.

  33. The matrix is invertible.

  34. The transformation doesn't destroy information.

  35. When you measure a state, it collapses into one of the component states. (This may be inaccurate.)

  36. You don't need to bring in consciousness etc. The collapse happens because the measurement causes the state to interact with the outside world.

  37. The probability of collapsing into a particular state is the squared magnitude of its complex weight.

  38. For some sets of weights, particularly after a transformation, the combined state cannot be separated into a tensor product of individual qbits. In this case, the individual qbits are entangled.

  39. That is the next part of why quantum computation is powerful.

  40. Entanglement means that if you measure one qbit then what you observe restricts what would be observed when you measure the other qbit.

  41. However that does not let you communicate.

  42. From page 171 of

    Quantum Computing for Computer Scientists 1st Edition

    All quantum algorithms work with the following basic framework:

    1. The system will start with the qubits in a particular classical state.
    2. From there the system is put into a superposition of many states.
    3. This is followed by acting on this superposition with several unitary operations.
    4. And finally, a measurement of the qubits.
    1. Ways to look at measurement:
      1. Converts qbit to classical bit.
      2. Is an interaction with the external world.
      3. Information is not lost, but leaks into the external world.
      4. Is an operator represented by a matrix.
      5. that is Hermitian, i.e., it's equal to its complex transpose.
      6. For physical systems, some operators compute the system's momentum, position, or energy.
      7. The matrix's eigenvalues are real.
      8. The result of the operation is one of the eigenvalues.
  43. More from

    Quantum Computing for Computer Scientists 1st Edition

    1. Compare byte with qbyte.
    2. State of byte is 8 bits.
    3. State of qbyte is 256 complex weights.
    4. They all get modified by each operation (aka matrix multiply).
    5. That is the power of quantum computing.
  44. The current limitations are that IBM does only a few qbits and that the operation is noisy.

  45. https://en.m.wikipedia.org/wiki/Bloch_sphere:

    1. The state of a qbit can be represented as a point on or in a sphere of radius 1.
    2. E.g., |1> is the north pole, |0> the south pole.
    3. Many operations are rotations.
  46. Common operations (aka gates):

    https://en.wikipedia.org/wiki/Quantum_logic_gate

    1. Hadamard.

      Creates a superposition.

      https://cs.stackexchange.com/questions/63859/intuition-behind-the-hadamard-gate

    2. Toffoli, aka CCNOT.

      Universal for classical boolean functions.

      (a,b,c) -> (a,b, c xor (a and b))

      https://en.wikipedia.org/wiki/Toffoli_gate

    3. Fredkin, aka CSWAP.

      https://en.wikipedia.org/wiki/Fredkin_gate

      3 inputs. Swaps last 2 if first is true.

      sample app: 5 gates make a 3-bit full adder.

  47. Algorithms:

    1. Some, but not all, are faster.
    2. Bounded-error quantum polynomial time (BQP)
      1. "is the class of decision problems solvable by a quantum computer in polynomial time, with an error probability of at most 1/3 for all instances" - https://en.wikipedia.org/wiki/BQP
      2. Includes integer factorization and discrete log.
      3. Relation to NP is unknown (big unsolved problem).
    3. Searching problems:
      1. Find the answer to a puzzle.
      2. Math examples: factor an integer, solve a polynonial equation.
      3. Testing validity of a putative solution is easy.
      4. Finding that putative solution, naively, requires testing all possibilities.
      5. Quantum computation can solve some searching problems faster.
      6. This is probabilistic or noisy; often the found solution is wrong.
      7. So you repeat the computation enough times that the error rate is acceptably low.
      8. Some classical algorithms are similar. There is an excellent probabilistic primality algorithm.
      9. The quantum algorithms are quite complex. (i.e., I'm still learning them.)
    4. Algorithms, another view
      1. Hadamard matrix rotates the pure state to an entangled superposition.
      2. Then we operate in parallel on each state in the superposition.
      3. Finally we separate out the desired answer.
    5. Grover's algorithm:
      1. https://en.wikipedia.org/wiki/Grover%27s_algorithm
      2. Given a black box with N inputs and 1 output.
      3. Exactly one input makes the output 1.
      4. Problem: which one?
      5. Classical solution: Try each input, T=N.
      6. Quantum: $T=\sqrt(N)$.
      7. Probabilistic.
      8. Apps: mean, median, reverse a crypto hash, find collisions, generate false blocks.
      9. Can extend to quantum partial search.
      10. Grover's algorithm is optimal.
      11. This suggests that NP is not in BQP .
    6. Shor's algorithm:
      1. Factorize an integer.
      2. in BQP.
      3. almost exponentially faster than best classical algorithm.
      4. Largest examples I can find:
        1. 56153 = 233 × 241.
        2. https://medium.com/@aditya.yadav/rsa-2048-cracked-using-shors-algorithm-on-a-quantum-computer-660cb2297a95
  48. https://quantumexperience.ng.bluemix.net/qx/tutorial ctd.

6   My RPI course

I've created ECSE-4964 Quantum Computer Programming, CRN 30195. Preliminary syllabus.

This will force me to learn the material.

As of 3/25/2020, 17 students have preregistered.

7   IBM quantum computing

  1. They have several quantum computers.

  2. The older ones are freely available on the web.

  3. Those have 5 and 14 qbits.

  4. You submit a batch job and get emailed when it runs.

  5. IBM github site: https://github.com/Qiskit with

    1. a free simulator.

      It doesn't match all the physical complexity of the real computer, but it's a good start.

    2. and tutorials and presentations:

  6. and a SW development framework. https://qiskit.org/

  7. You can create a quantum computation program either by

  1. designing a circuit, or
  2. using a programming language.

8   Quantum computing on youtube

  1. Quantum Algorithms (2:52)

    Which problems can quantum computers solve exponentially faster than classical computers? David Gosset, IBM quantum computing research scientist, explains why algorithms are key to finding out.

  2. David Deutsch - Why is the Quantum so Strange? (8:43)

  3. Grover's Algorithm (9:57)

    An overview of Grover's Algorithm. An unstructured search algorithm that can find an item in a list much faster than a classical computer can. Several sources are listed.

  4. Bob Sutor demonstrates the IBM Q quantum computer (6:53)

  5. Can we make quantum technology work? | Leo Kouwenhoven | TEDxAmsterdam (18:19)

  6. "Spooky" physics | Leo Kouwenhoven | TEDxDelft (18:00)

  7. David Deutsch - Why is the Quantum so Strange? (8:43)

  8. Quantum Computing Concepts – Quantum Hardware (3:22)

  9. IBM Introduces First Integrated Quantum Computing System for Commercial Use

  10. The World’s First Integrated Quantum Computing System (1:06)

8.2   Shor's algorithm

Shor on, what is Shor's factoring algorithm? (2:09) https://www.youtube.com/watch?v=hOlOY7NyMfs

Hacking at Quantum Speed with Shor's Algorithm (16:35) https://kcts9.org/programs/digital-studios-infinite-series/episodes/0121

43 Quantum Mechanics - Quantum factoring Period finding (19:27) https://www.youtube.com/watch?v=crMM0tCboZU

44 Quantum Mechanics - Quantum factoring Shor's factoring algorithm (25:42) https://www.youtube.com/watch?v=YhjKWAMFBUU

8.4   Others

Experiment with Basic Quantum Algorithms (Ali Javadi-Abhari, ISCA 2018) (19:05) https://www.youtube.com/watch?v=M1UHi9UXTWI&list=PLOFEBzvs-VvruANdBhTb-9YRDes07pZWQ&index=2

PAR Class 19, Thu 2020-04-02

1   Project proposal

To the several people who haven't uploaded it to gradescope: please do.

3   Thrust

  1. Thrust is an API that looks like STL. Its backend can be CUDA, OpenMP, or sequential host-based code.

  2. The online Thrust directory structure is a mess. Three main sites appear to be these:

    1. https://github.com/thrust -

      1. The best way to install it is to clone from here.
      2. The latest version of the examples is also here.
      3. The wiki has a lot of doc.
    2. https://thrust.github.io/

      This points to the above site.

    3. https://developer.nvidia.com/thrust

      This has links to other Nvidia docs, some of which are obsolete.

    4. http://docs.nvidia.com/cuda/thrust/index.html

      easy-to-read, thorough, obsolete, doc

    5. https://code.google.com/ - no longer exists.

  3. Functional-programming philosophy.

  4. Many possible backends: host, GPU, OpenMP, TBB...

  5. Easier programming, once you get used to it.

  6. Code is efficient.

  7. Uses some unusual C++ techniques, like overloading operator().

  8. Since the Stanford slides were created, Thrust has adopted unified addressing, so that pointers know whether they are host or device.

  9. On parallel in /parallel-class/thrust/ are many little demo programs from the thrust distribution, with my additions.

  10. CUDACast videos on Thrust:

    CUDACast #.15 - Introduction to Thrust

    CUDACast #.16 - Thrust Algorithms and Custom Operators

  11. Thrust is fast because the functions that look like they would need linear time really take only log time in parallel.

  12. In functions like reduce and transform, you often see an argument like thrust::multiplies<float>(). The syntax is as follows:

    1. thrust::multiplies<float> is a class.
    2. It overloads operator().
    3. However, in the call to reduce, thrust::multiplies<float>() is calling the default constructor to construct a variable of class thrust::multiplies<float>, and passing it to reduce.
    4. reduce will treat its argument as a function name and call it with an argument, triggering operator().
    5. You may also create your own variable of that class, e.g., thrust::multiplies<float> foo. Then you just say foo in the argument list, not foo().
    6. The optimizing compiler will replace the operator() function call with the defining expression and then continue optimizing. So, there is no overhead, unlike if you passed in a pointer to a function.
  13. Sometimes, e.g., in saxpy.cu, you see saxpy_functor(A).

    1. The class saxpy_functor has a constructor taking one argument.
    2. saxpy_functor(A) constructs and returns a variable of class saxpy_functor and stores A in the variable.
    3. The class also overloads operator().
    4. (Let's call the new variable foo). foo() calls operator() for foo; its execution uses the stored A.
    5. Effectively, we did a closure of saxpy_functor; this is, we bound a property and returned a new, more restricted, variable or class.

3.1   Bug

I found and reported a bug in version 100904. This version does not work with OpenMP. It was immediately closed because they already knew about it. They just hadn't told us users.

Awhile ago I reported a bug in nvcc, where it went into an infinite loop for a certain array size. The next minor version of CUDA was released the next day.

Two observations:

  1. I'm good at breaking SW by expecting it to meet its specs.
  2. Nvidia is responsive, which I like.

3.2   Stanford's lectures

  1. Continue Stanford's parallel course notes.

    Lecture 8: Thrust ctd, starting at slides 24.

    There's a lot of stuff here.

3.3   Alternate docs in /parallel-class/thrust/doc/

  1. An_Introduction_To_Thrust.pdf
  2. GTC_2010_Part_2_Thrust_By_Example.pdf

PAR Class 18, Mon 2020-03-30

1   Ensure that you're in piazza

I use this for quick announcements that are not so much of permanent interest, and for things that don't necessarily need to be on the global internet forever.

I think I added everyone who wasn't already in it, but for complicated reasons might have missed someone.

So, if you're not in it, please add yourself or email me to add you.

I'll send a test message. If you don't get it, check your spam filter. RPI's spam filter recently blocked my own messages to piazza being forwarded to myself.

2   My Quantum Intro blog posting

I prepared it for an internal RPI research discussion last week. RPI faculty in several departments are considering how to do research on this. A group of RPI people, including two vice presidents, visited IBM before the break to talk about this. I'll work this into this course later, but you're welcome to read it now.

3   Linux HMM (Heterogeneous Memory Management)

This is hardware support to make programming devices like GPUs easier. It took years to get into the official kernel, presumably because you don't want bugs in memory management.

This is also a nice intro into current operating systems concerns. Do our operating systems courses talk about this?

  1. https://www.kernel.org/doc/html/v4.18/vm/hmm.html
  2. https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=5&ved=2ahUKEwiCuM-y2t7gAhUD24MKHZWlCeYQFjAEegQIBhAC&url=http%3A%2F%2Fon-demand.gputechconf.com%2Fgtc%2F2017%2Fpresentation%2Fs7764_john-hubbardgpus-using-hmm-blur-the-lines-between-cpu-and-gpu.pdf&usg=AOvVaw1c7bYo2YO5n8OtD0Vw9hbs

4   Several forms of C++ functions

  1. 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.

  2. 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.

  3. Lambda, or anon function.

    auto add = [](int a, int b) { return a+b;};

    This is local to the containing block.

    This form optimizes well.

  4. 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.

PAR Class 17, Thu 2020-03-26

Table of contents

1   Mediatesite

The videos of our classes will be in my Mediatesite channel ECSE-4740 Applied Parallel Computing for Engineers.

Please report any problems. I have no easy way to see the system from a student's perspective.

2   Thrust

  1. Stanford's parallel course notes.

    Starting with lecture 5, which shows us a little CUDA code and, more important, optimizing techniques and parallel paradigms.

    I showed starting from lecture 5 through lecture 8, slide 19.

  2. The github repository, with demo is https://github.com/thrust/thrust.git .

    Nvidia's proprietary version is slightly newer.

  3. The most comprehensive doc is online at http://thrust.github.io/doc/index.html

    It is badly written and slightly obsolete.

  4. There are various tutorials online, most obsolescent. E.g., they don't use C++-11 lambdas, which are a big help.

  5. Look at some Thrust programs in /parallel-class/cuda/thrust

  6. One Nvidia-sponsored alternative is agency, at https://github.com/agency-library/ .

  7. There are other alternatives that I'll mention later.

  8. The alternatives are lower-level (= faster and harder to use) and newer (= possibly less debugged, fewer users).

  9. However OpenACC now looks competitive.

  10. The biggest problem with Thrust is that it appears that Nvidia has de-emphasized it, and appears to be making it proprietary. The two latest versions of Thrust do not allow Intel as a backend. That is a bad sign, and may be a reason to stop using it. The Thrust developers say that this is temporary but they haven't fixed it in the release version.

PAR Class 16, Mon 2020-03-23

1   About this unprecedented situation

RPI wants to continue to give you a solid education.

We recognize that new problems may arise and will try to be humane.

You will still have to study.

Anything listed here is only a best attempt and might be changed if there's a good reason.

Your feedback is always welcome.

2   Course computer tools

2.1   Webex

For the rest of the semester, the idea is that I'll still lecture at the appointed times, Mon and Thurs at noon eastern time.

However, now I'll try to lecture with Webex. You can access it via your favorite browser. Or, you can use an app on some platforms like the Ipad.

The lectures will be recorded so that you can rewatch them later.

I'll post the link on piazza with email to you before the lecture.

2.2   Piazza

I'll use piazza---

  1. to push announcements to the class,
  2. to post material that might not be completely public,
  3. for questions and answers.

2.3   This blog

This blog will continue to be sort of a permanent record of the class.

2.4   Gradescope

Gradescope will continue to be used for grading.

2.5   parallel.ecse

parallel.ecse will continue to be available remotely.

3   Today

3.1   Final round 2 student talks

Two remaining students will present your talks.

If possible, post your slides in advance or email them to me for posting.

  1. Elizabeth .
  2. Garrett.
  3. Mike.

3.2   OpenACC

Quickly finish the 3 slide sets.

From https://www.openacc.org/events/openacc-online-course-2018.

My local copy on parallel: /parallel-class/openacc/online-course

3.3   CUDA

I've mentioned this many times. Now we'll get into details.

  1. Stanford's parallel course notes.
  1. Lecture 5: Finish CUDA,
  2. Lectures 6, 7: Some parallel patterns.
  1. Sample programs.
    1. /local/cuda/samples has many programs by Nvidia. Some interesting ones:
      1. /local/cuda/samples/1_Utilities/deviceQuery/deviceQuery describes the host's GPUs.
      2. /local/cuda/samples/0_Simple/ does some benchmarks.
    2. Stanfords examples are in parallel-class/stanford/tutorials .

PAR Class 14, Mon 2020-03-02

1   Student talks, round 2, day 1

  1. Joseph & Alexander
  2. Kevin
  3. Chris
  4. Ross
  5. David
  6. John & Hayley

8

2   OpenACC slides

To fill in the remaining time.

From https://www.openacc.org/events/openacc-online-course-2018

My local copy on parallel: /parallel-class/openacc/online-course

PAR Class 12, Mon 2020-02-24

1   Term project

  1. See the syllabus.
  2. Proposal due March 12.
  3. Progress reports on March 26, April 9 (Thu)
  4. Presentations in class April 20 (Mon), 23 (Thu), 27 (Mon).
  5. Paper etc due on Wed April 29 (last class).

2   No class Thu Feb 27

A group of us will be visiting IBM's Quantum Computing group.

In preparation for quantum computing, which I'll start in a few weeks, read Quantum Computing for Computer Scientists slides and video

3   Types of memory allocation

Here's a brief overview of my understanding of the various places that you can assign memory in a program.

  1. Static. Define a fixed-size array global array. The variable is constructed at compile time, so accesses might perhaps be faster. Global vars with non default initial values increase the executable file size. If they're large enough, you need to use the compiler option -mcmodel=medium or -mcmodel=large. They cause the compiler to generate wider addresses. I don't know the effect on the program's size or speed, but suspect that it's small.

  2. Stack. Define local arrays, that are created and freed as the routine is entered and exited. Their addresses relative to the base of this call frame may be constant. The default stack size is 8MB. You can increase this with the command ulimit or in the program as shown in stacksize.cc. I believe that in OpenMP, the max stacksize may be allocated when each thread is created. Then, a really big stackssize might have a penalty.

  3. Heap. You use new and destroy. Variables are constructed whenever you want. The more objects on the heap, the more time that each new or destroy takes. If you have lots of objects consider using placement new or creating an array of them.

    For CUDA, some variables must be on the heap.

I like to use static, then stack, and heap only when necessary. However, allocating few but large, blocks on the heap is also fast.

Google's allocator is noticeably better than the default one. To use it, link your programs with -ltcmalloc. You can often use it on an existing executable foo thus:

LD_PRELOAD="/usr/lib/libtcmalloc.so" foo

I found it to save 15% to 30% in time.

Another memory concern is speed. Parallel has a NUMA (Non Uniform Memory Architecture). It has two 14-core Xeons. Each core has 128GB of main memory. Although all 256GB are in a common address space, accessing memory on same core as the thread is running on is faster.

The following is what I think based on some research, but may be wrong: A 4KB page of memory is assigned to a specific core when it is first written (not when it is reserved). So, each page of a large array may be on a different core. This can be used to optimize things. This gets more fun with 8-processor systems.

All that is separate from cache issues.

You can also assign your OpenMP threads to specific cores. This affects speed in ways I don't understand. The issues are resource sharing vs conflicts.

4   parallel.ecse hardware details

I put the invoice on parallel.ecse in /parallel-class/ . It gives the hardware specifics.

Since the initial purchase, parallel has been modified:

  1. The Intel MIC coprocessor was removed.
  2. The Nvidia RTX 8000 was added.

5   Nvidia GPU summary

Here's a summary of the Nvidia Pascal GP104 GPU architecture as I understand it. It's more compact than I've found elsewhere. I'll add to it from time to time. Some numbers are probably wrong.

  1. The host is the CPU.

  2. The device is the GPU.

  3. The device contains 20 streaming multiprocessors (SMs).

    Different GPU generations have used the terms SMX or SMM.

  4. A thread is a sequential program with private and shared memory, program counter, etc.

  5. Threads are grouped, 32 at a time, into warps.

  6. Warps of threads are grouped into blocks.

    Often the warps are only implicit, and we consider that the threads are grouped directly into blocks.

    That abstract hides details that may be important; see below.

  7. Blocks of threads are grouped into a grid, which is all the threads in the kernel.

  8. A kernel is a parallel program executing on the device.

    1. The kernel runs potentially thousands of threads.
    2. A kernel can create other kernels and wait for their completion.
    3. There may be a limit, e.g., 5 seconds, on a kernel's run time.
  9. Thread-level resources:

    1. Each thread can use up to 255 fast registers. Registers are private to the thread.

      All the threads in one block have their registers allocated from a fixed pool of 65536 registers. The more registers that each thread uses, the fewer warps in the block can run simultaneously.

    2. Each thread has 512KB slow local memory, allocated from the global memory.

    3. Local memory is used when not enough registers are available, and to store thread-local arrays.

  10. Warp-level resources:

    1. Threads are grouped, 32 at a time, into warps.

    2. Each warp executes as a SIMD, with one instruction register. At each cycle, every thread in a warp is either executing the same instruction, or is disabled. If the 32 threads want to execute 32 different instructions, then they will execute one after the other, sequentially.

      If you read in some NVidia doc that threads in a warp run independently, then continue reading the next page to get the info mentioned in the previous paragraph.

    3. If successive instructions in a warp do not depend on each other, then, if there are enough warp schedulers available, they may be executed in parallel. This is called Instruction Level Parallelism (ILP).

    4. For an array in local memory, which means that each thread will have its private copy, the elements for all the threads in a warp are interleaved to potentially increase the I/O rate.

      Therefore your program should try to have successive threads read successive words of arrays.

    5. A thread can read variables from other threads in the same warp, with the shuffle instruction. Typical operation are to read from the K-th next thread, to do a butterfly permutation, or to do an indexed read. This happens in parallel for the whole warp, and does not use shared memory.

    6. A warp vote combines a bit computed by each thread to report results like all or any.

  11. Block-level resources:

    1. A block may contain up to 1024 threads.

    2. Each block has access to 65536 fast 32-bit registers, for the use of its threads.

    3. Each block can use up to 49152 bytes of the SM's fast shared memory. The block's shared memory is shared by all the threads in the block, but is hidden from other blocks.

      Shared memory is basically a user-controllable cache of some global data. The saving comes from reusing that shared data several times after you loaded it from global memory once.

      Shared memory is interleaved in banks so that some access patterns are faster than others.

    4. Warps in a block run asynchronously and run different instructions. They are scheduled and executed as resources are available.

    5. However they are all running the same instruction sequence, perhaps at different points in it.

    6. That is call SPMD, single program multiple data.

    7. The threads in a block can be synchonized with __syncthreads().

      Because of how warps are scheduled, that can be slow.

    8. The threads in a block can be arranged into a 3D array, up to 1024x1024x64.

      That is for convenience, and does not increase performance (I think).

    9. I'll talk about textures later.

  12. Streaming Multiprocessor (SM) - level resources:

    1. Each SM has 128 single-precision CUDA cores, 64 double-precision units, 32 special function units, and 32 load/store units.

    2. In total, the GPU has 2560 CUDA cores.

    3. A CUDA core is akin to an ALU. The cores, and all the units, are pipelined.

    4. A CUDA core is much less powerful than one core of an Intel Xeon. My guess is 1/20th.

    5. Beware that, in the CUDA C Programming Guide, NVidia sometimes calls an SM a core.

    6. The limited number of, e.g., double precision units means that an DP instruction will need to be scheduled several times for all the threads to execute it. That's why DP is slower.

    7. Each SM has 4 warp schedulers and 8 instruction dispatch units.

    8. 64 warps can simultaneously reside in an SM.

    9. Therefore up to 32x64=2048 threads can be executed in parallel by an SM.

    10. Up to 16 blocks that can simultaneously be resident in an SM.

      However, if each block uses too many resources, like shared memory, then this number is reduced.

      Each block sits on only one SM; no block is split. However a block's warps are executed asynchronously (until synced).

    11. Each SM has 64KiB (?) fast memory to be divided between shared memory and an L1 cache. Typically, 48KiB (96?) is used for the shared memory, to be divided among its resident blocks, but that can be changed.

    12. The 48KB L1 cache can cache local or global memory.

    13. Each SM has a read-only data cache of 48KB to cache the global constant memory.

    14. Each SM has 8 texture units, and many other graphics capabilities.

    15. Each SM has 256KB of L2 cache.

  13. Grid-level resources:

    1. The blocks in a grid can be arranged into a 3D array. up to \((2^{31}-1, 2^{16}-1, 2^{16}-1)\).
    2. Blocks in a grid might run on different SMs.
    3. Blocks in a grid are queued and executed as resources are available, in an unpredictable parallel or serial order. Therefore they should be independent of each other.
    4. The number of instructions in a kernel is limited.
    5. Any thread can stop the kernel by calling assert.
  14. Device-level resources:

    1. There is a large and slow 48GB global memory, which persists from kernel to kernel.

      Transactions to global memory are 128 bytes.

      Host memory can also be memory-mapped into global memory, although the I/O rate will be lower.

      Reading from global memory can take hundreds of cycles. A warp that does this will be paused and another warp started. Such context switching is very efficient. Therefore device throughput stays high, although there is a latency. This is called Thread Level Parallelism (TLP) and is a major reason for GPU performance.

      That assumes that an SM has enough active warps that there is always another warp available for execution. That is a reason for having warps that do not use all the resources (registers etc) that they're allowed to.

    2. There is a 2MB L2 cache, for sharing data between SMs.

    3. There is a 64KiB Small and fast global constant memory, , which also persists from kernel to kernel. It is implemented as a piece of the global memory, made fast with caches.

      (Again, I'm still resolving this apparent contradiction).

    4. Grid Management Unit (GMU) schedules (pauses, executes, etc) grids on the device. This is more important because grids can start other grids (Dynamic Parallelism).

    5. Hyper-Q: 32 simultaneous CPU tasks can launch kernels into the queue; they don't block each other. If one kernel is waiting, another runs.

    6. CUDA Work Distributor (CWD) dispatches 32 active grids at a time to the SMs. There may be 1000s of grids queued and waiting.

    7. GPU Direct: Other devices can DMA the GPU memory.

    8. The base clock is 1607MHz.

    9. GFLOPS: 8873.

    10. Memory bandwidth: 320GB/s

  15. GPU-level resources:

    1. Being a Geforce product, there are many graphics facilities that we're not using.
    2. There are 4 Graphics processing clusters (GPCs) to do graphics stuff.
    3. Several perspective projections can be computed in parallel, for systems with several displays.
    4. There's HW for texture processing.
  16. Generational changes:

    1. With each new version, Nvidia tweaks the numbers. Some get higher, others get lower.
      1. E.g., Maxwell had little HW for double precision, and so that was slow.
      2. Pascal's clock speed is much higher.
  17. Refs:

    1. The CUDA program deviceDrv.
    2. http://developer.download.nvidia.com/compute/cuda/compute-docs/cuda-performance-report.pdf
    3. http://international.download.nvidia.com/geforce-com/international/pdfs/GeForce_GTX_1080_Whitepaper_FINAL.pdf
    4. Better Performance at Lower Occupancy, Vasily Volkov, UC Berkeley, 2010.
    5. https://www.pgroup.com/lit/articles/insider/v2n1a5.htm - well written but old.

    (I'll keep adding to this. Suggestions are welcome.)

6   More CUDA

  1. CUDA function qualifiers:

    1. __global__ device function called from host, starting a kernel.
    2. __device__ device function called from device function.
    3. __host__ (default) host function called from host function.
  2. CUDA variable qualifiers:

    1. __shared__
    2. __device__ global
    3. __device__ __managed__ automatically paged between host and device.
    4. __constant__
    5. (nothing) register if scalar, or local if array or if no more registers available.
  3. If installing CUDA on your machine, this repository seems best:

    http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64

    That includes the Thrust headers but not example programs.

7   Unionfs: Linux trick of the day

  1. aka overlay FS, translucent FS.

  2. If a, b are directories, and m is an empty directory, then

    unionfs -o cow a=RW:b m

    makes m to be a combo of a and b, with a being higher priority

  3. Writing a file into m writes it in a.

  4. Changing a file in b writes the new version into a

  5. Deleting a file in b causes a white-out note to be stored in a.

  6. Unmount it thus:

    fusermount -u m

  7. None of this requires superuser.

  8. Application: making a read-only directory into a read-write directory.

  9. Note: IBM had a commercial version of this idea in its CP/CMS OS in the 1960s.

8   OpenCL

  1. Module 20.
  2. Apple's competition to CUDA.
  3. is largely CUDA but they changed the names.
  4. not interesting so long as Nvidia is dominant.

9   Nvidia GPU and accelated computing, ctd.

This material accompanies Programming Massively Parallel Processors A Hands-on Approach, Third Edition, David B. Kirk Wen-mei W. Hwu. I recommend it. (The slides etc are free but the book isn't.)

Finishing /parallel-class/GPU-Teaching-Kit-Accelerated-Computing, Module 21, OpenACC.

10   OpenACC

  1. Adds pragmas to C++ code, like OpenMP.

  2. Unlike OpenMP, targets accelerators, e.g., GPUs.

  3. Tries to be higher level than OpenMP.

  4. E.g., kernel pragma says to try to parallelize everything you can.

  5. Nevertheless, the more specific parallel pragma probably leads to better code.

  6. G++ does OpenACC badly.

  7. Use PGI compiler, which Nvidia bought.

  8. In parallel, I've installed it both directly and in a docker file.

  9. Good books:

    1. OpenACC for Programmers: Concepts and Strategies By: Sunita Chandrasekaran, Guido Juckeland kindle $31.19

    2. Parallel Programming with OpenACC By: Rob Farber kindle: $37.74

      https://github.com/rmfarber/ParallelProgrammingWithOpenACC.

PAR Class 11, Thu 2020-02-20

1   Term project

  1. See the syllabus.
  2. Proposal due March
  3. Progress reports on March 26, April 9 (Thu)
  4. Presentations in class April 20 (Mon), 23 (Thu), 27 (Mon).
  5. Paper etc due on Wed April 29 (last class).

2   No class Thu Feb 27

A group of us will be visiting IBM's Quantum Computing group.

On Monday I'll make suggestions for how to occupy your time.

3   Student talks in class, round 2

  1. Choose a topic (or group of topics) from the 589 on-demand sessions at the GPU Tech Conference.

  2. Summarize it in class. OK to show the whole presentation (or parts of it) with your commentary.

  3. Groups of two people are allowed. However, this time, please keep your talks to 6 min.

  4. Presentation dates: March 2 and 5.

  5. No need to sign up for your topic since there'll probably be few overlaps. However here's a signup site for your presentation date.

    https://doodle.com/poll/hwqrmeyxgsvk2mzk

    I've allowed up to 11 talks per day.

    Please enter your name and rcsid.

4   Nvidia conceptual hierarchy

As always, this is as I understand it, and could be wrong. Nvidia uses their own terminology inconsistently. They may use one name for two things (E.g., Tesla and GPU), and may use two names for one thing (e.g., module and accelerator). As time progresses, they change their terminology.

  1. At the bottom is the hardware micro-architecture. This is an API that defines things like the available operations. The last several Nvidia micro-architecture generations are, in order, Tesla (which introduced unified shaders), Fermi, Kepler, Maxwell (introduced in 2014), Pascal (2016), and Volta (2018).
  2. Each micro-architecture is implemented in several different microprocessors. E.g., the Kepler micro-architecture is embodied in the GK107, GK110, etc. Pascal is GP104 etc. The second letter describes the micro-architecture. Different microprocessors with the same micro-architecture may have different amounts of various resources, like the number of processors and clock rate.
  3. To be used, microprocessors are embedded in graphics cards, aka modules or accelerators, which are grouped into series such as GeForce, Quadro, etc. Confusingly, there is a Tesla computing module that may use any of the Tesla, Fermi, or Kepler micro-architectures. Two different modules using the same microprocessor may have different amounts of memory and other resources. These are the components that you buy and insert into a computer. A typical name is GeForce GTX1080.
  4. There are many slightly different accelerators with the same architecture, but different clock speeds and memory, e.g. 1080, 1070, 1060, ...
  5. The same accelerator may be manufactured by different vendors, as well as by Nvidia. These different versions may have slightly different parameters. Nvidia's reference version may be relatively low performance.
  6. The term GPU sometimes refers to the microprocessor and sometimes to the module.
  7. There are at least four families of modules: GeForce for gamers, Quadro for professionals, Tesla for computation, and Tegra for mobility.
  8. Nvidia uses the term Tesla in two unrelated ways. It is an obsolete architecture generation and a module family.
  9. Geoxeon has a (Maxwell) GeForce GTX Titan and a (Kepler) Tesla K20xm. Parallel has a (Volta) RTX 8000 and (Pascal) GeForce GTX 1080. We also have an unused (Kepler) Quadro K5000.
  10. Since the highest-end (Tesla) modules don't have video out, they are also called something like compute modules.

5   GPU range of speeds

Here is an example of the wide range of Nvidia GPU speeds; all times are +-20%.

The Quadro RTX 8000 has 4608 CUDA cores @ 1.77GHz and 48GB of memory. matrixMulCUBLAS runs at 5310 GFlops. The specs claim 16 TFlops. However those numbers understate its capabilities because it also has 576 Tensor cores and 72 ray tracing cores to cast 11G rays/sec.

The GeForce GTX 1080 has 2560 CUDA cores @ 1.73GHz and 8GB of memory. matrixMulCUBLAS runs at 3136 GFlops. However the reported time (0.063 msec) is so small that it may be inaccurate. The quoted speed of the 1080 is about triple that. I'm impressed that the measured performance is so close.

The Quadro K2100M in my Lenovo W540 laptop has 576 CUDA cores @ 0.67 GHz and 2GB of memory. matrixMulCUBLAS runs at 320 GFlops. The time on the GPU was about .7 msec, and on the CPU 600 msec.

It's nice that the performance almost scaled with the number of cores and clock speed.

6   CUDA

6.1   Versions

  1. CUDA has a capability version, whose major number corresponds to the micro-architecture generation. Kepler is 3.x. The K20xm is 3.5. The GTX 1080 is 6.1. The RTX 8000 is 7.5. Here is a table of the properties of different compute capabilities. However, that table is not completely consistent with what deviceQuery shows, e.g., the shared memory size.
  2. nvcc, the CUDA compiler, can be told which capabilities (aka architectures) to compile for. They can be given as a real architecture, e.g., sm_61, or a virtual architecture. e.g., compute_61.
  3. The CUDA driver and runtime also have a software version, defining things like available C++ functions. The latest is 10.1. This is unrelated to the capability version.

6.2   Misc

  1. With CUDA, the dominant problem in program optimization is optimizing the data flow. Getting the data quickly to the cores is harder than processing it. It helps big to have regular arrays, where each core reads or writes a successive entry.

    This is analogous to the hardware fact that wires are bigger (hence, more expensive) than gates.

  2. That is the opposite optimization to OpenMP, where having different threads writing to adjacent addresses will cause the false sharing problem.

  3. Nvidia CUDA FAQ

    1. has links to other Nvidia docs.
    2. can be a little old.

7   Nvidia GPU and accelated computing, ctd.

This material accompanies Programming Massively Parallel Processors A Hands-on Approach, Third Edition, David B. Kirk Wen-mei W. Hwu. I recommend it. (The slides etc are free but the book isn't.)

Continuing /parallel-class/GPU-Teaching-Kit-Accelerated-Computing, starting at Modules 17 slide 14.

PAR Class 10, Tues 2020-02-18

1   More on ssh

  1. ssh-agent on the source machine starts a daemon to manage your keys. I start it in a login script.
  2. ssh-add on the source machine creates a key pair in ~/.ssh . Do it once.
  3. ssh-add -l lists the keys registered with ssh-agent, i.e., that are available to use with future ssh commands in this session.
  4. ~/.ssh/authorized_keys on the destination machine stores the public keys of source machines allowed to connect. Copy your source machines' public keys into it. Do that once.
  5. If you use a different user name on the destination machine, instead of doing user@destination all the time, you can set defaults on the source machine, for the destination user names, in ~/.ssh/config.
  6. ssh -v destination shows the handshaking.
  7. Now ssh, scp, Emacs tramp mode, mounting the remote filesystem, etc. work w/o typing passwords.

2   PGI compilers on parallel.ecse

I've installed pgc++ directly. Run it thus:

/local/pgi/linux86-64/19.10/bin/pgc++ foo.cc -o foo

Here's a set of good switches:

/local/pgi/linux86-64/19.10/bin/pgc++ -fast -mp -Msafeptr -O3 -Minfo=all -Mconcur=allcores  -ta:tesla -acc foo.cc -o foo

In parallel.ecse:/parallel-class/matmul, I experiment with gcc and pgi with openmp running on the Xeon, and openacc running on the GPU, multiplying matrices stored as global data, on the local stack, as STL vectors of vectors, and as a heap array. Some of my conclusions:

  1. For sequential code, g++ is twice as fast as pgic++.
  2. OpenMP works well.
  3. OpenACC works only on pgc++. It is very fast.

3   Nvidia GPU and accelated computing, ctd.

This material accompanies Programming Massively Parallel Processors A Hands-on Approach, Third Edition, David B. Kirk Wen-mei W. Hwu. I recommend it. (The slides etc are free but the book isn't.)

Continuing /parallel-class/GPU-Teaching-Kit-Accelerated-Computing, Modules 13 to 17 slide 14.

4   Notes about parallel.ecse

Since it has 256GB of main memory, there's no paging, and pinning memory is not a problem.

Linux now has Heterogeneous Memory Management (HMM) .

PAR Homework 5, due Thu 2020-02-20, noon

Rules

  1. Submit the answers to Gradescope.
  2. You may do homeworks in teams of 2 students. Create a gradescope team and make one submission with both names.
  3. For redundancy, at the top of your submitted homework write what it is and who you are. E.g., "Parallel Homework 2, 1/30/20, by Boris Badenov and Natasha Fatale".
  4. Each question is 10 points.

Questions

  1. Assume that a kernel is launched with 1000 thread blocks each of which has 512 threads. If a variable is declared as a shared memory variable, how many versions of the variable will be created through the lifetime of the execution of the kernel? (module 4)

  2. Assume that each atomic operation in a DRAM system has a total latency of 100ns. What is the maximal throughput we can get for atomic operations on the same global memory variable? (module 7)

  3. For a processor that supports atomic operations in L2 cache, assume that each atomic operation takes 4ns to complete in L2 cache and 100ns to complete in DRAM. Assume that 90% of the atomic operations hit in L2 cache. What is the approximate throughput for atomic operations on the same global memory variable?

  4. For the following basic reduction kernel code fragment, if the block size is 1024 and warp size is 32, how many warps in a block will have divergence during the iteration where stride is equal to 1? (module 9):

    unsigned int t = threadIdx.x;
    Unsigned unsigned int start = 2*blockIdx.x*blockDim.x;
    partialSum[t] = input[start + t];
    partialSum[blockDim.x+t] = input[start+ blockDim.x+t];
    for (unsigned int stride = 1; stride <= blockDim.x; stride *= 2)
    {
    __syncthreads();
    if (t % stride == 0) {partialSum[2*t]+= partialSum[2*t+stride];}
    }
    
  5. In the previous question, how many warps in a block will have divergence during the iteration where stride is equal to 16?

  6. For the work inefficient scan kernel based on reduction trees, assume that we have 1024 elements, which of the following gives the closest approximation of the number of add operations performed? (module 10)

    1. (1024-1)*2
    2. (512-1)*2
    3. 1024*1024
    4. 1024*10
  7. Which of the following statements is true? (module 14)

    1. Data transfer between CUDA device and host is done by DMA hardware using virtual addresses.
    2. The OS always guarantees that any memory being used by DMA hardware is not swapped out.
    3. If a pageable data is to be transferred by cudyMemcpy(), it needs to be first copied to a pinned memory buffer before transferred.
    4. Pinned memory is allocated with cudaMalloc() function.
  8. What is the CUDA API call that makes sure that all previous kernel executions and memory copies in a device have been completed?

    1. __syncthreads()
    2. cudaDeviceSynchronize()
    3. cudaStreamSynchronize()
    4. __barrier()

Total: 90 pts.

PAR Class 9, Thu 2020-02-13

1   Nvidia GPU and accelated computing, ctd.

This material accompanies Programming Massively Parallel Processors A Hands-on Approach, Third Edition, David B. Kirk Wen-mei W. Hwu. I recommend it. (The slides etc are free but the book isn't.)

Continuing /parallel-class/GPU-Teaching-Kit-Accelerated-Computing, Modules 9 to 12.

PAR Class 8, Mon 2020-02-10

1   Docker

Docker is worth learning, apart from its use by Nvidia for parallel computing. You might also look up Kubernetes.

  1. https://www.docker.com/
  2. https://www.zdnet.com/article/what-is-docker-and-why-is-it-so-darn-popular/
  3. https://opensource.com/resources/what-docker

On parallel, I think that docker is probably secure, but am not certain. In return for my allowing access to docker on parallel, I expect you to report, and not to exploit, holes that you might discover.

Compiling:

  1. docker run --gpus all -v $PWD:/tmp -it nvcr.io/hpc/pgi-compilers:ce
  2. Inside docker: pcg++ -mp -Minfo=all foo.cc

2   Nvidia GPU and accelated computing, ctd.

This material accompanies Programming Massively Parallel Processors A Hands-on Approach, Third Edition, David B. Kirk Wen-mei W. Hwu. I recommend it. (The slides etc are free but the book isn't.)

Continuing /parallel-class/GPU-Teaching-Kit-Accelerated-Computing, Modules 4 to 8.

PAR Homework 4, due Thu 2020-02-13, noon

Rules

  1. Submit the answers to Gradescope.
  2. You may do homeworks in teams of 2 students. Create a gradescope team and make one submission with both names.
  3. For redundancy, at the top of your submitted homework write what it is and who you are. E.g., "Parallel Homework 2, 1/30/20, by Boris Badenov and Natasha Fatale".

Questions

These may require some research.

  1. (10 points) Compare and contrast these different types of memory on the Nvidia GPU. How big are they? How fast are they? How global is their visibility?
    1. register
    2. shared
    3. local
    4. global
  2. (10 points) Compare and contrast on size, synchronization of components, order in hierarchy.
    1. thread block
    2. thread warp
    3. grid
  3. (10 points) In what way is the simple CUDA example in Module 2 obsolete?
  4. (10 points) On parallel, according to /local/cuda/samples/0_Simple/matrixMulCUBLAS how many FLOPS is the RTX 8000 on parallel? How does that compare to your program (that didn't use the GPU)?

Total: 40 pts.

PAR Class 7, Thu 2020-02-06

1   Docker on parallel

  1. I've installed docker, a popular lightweight virtualization system, on parallel, because Nvidia uses it to distribute SW.

  2. Docker runs images that define virtual machines.

  3. Docker images share resources with the host, in a controlled manner.

  4. You can install private copies of images, or to see what images I've installed, do: docker images .

  5. Run the hello-world image thus: docker run hello-world

  6. Here's a more complicated example:

    docker run -it --mount type=bind,source=/parallel-class,destination=/parallel-class --mount type=bind,source=$HOME,destination=/home --gpus=all nvidia/cuda:10.1-devel

    This interactively runs a virtual machine with

    1. Nvidia's CUDA development tools
    2. access to parallel's GPUs
    3. access to parallel's /parallel-class, mounted locally at /parallel-class .
    4. access to your home dir, mounted at /home.
  7. E.g., go into /parallel-class/openmp/rpi and run some programs.

  8. Copy some .cc files to your home dir, compile, and run them.

  9. There are ways to make the image's contents persistent. E.g., you can customize and save an image.

  10. For simple images, which is not nvidia/cuda, starting the image is so cheap that you can do it to run one command, and encapsulate the whole process in a shell function. More later. However, e.g.,

    docker run --gpus=all nvidia/cuda:10.1-devel nvidia-smi

  11. parallel has CUDA sample programs in /local/cuda/samples. To make them available in a docker image, include -v local/cuda/samples:/samples

2   Nvidia GPU and accelated computing, ctd.

Continuing /parallel-class/GPU-Teaching-Kit-Accelerated-Computing at Module 3.

PAR Class 6, Mon 2020-02-03

1   Student talks (round 1) finished

Note: in a month, we'll have another round.

2   Nvidia GPU and accelated computing

This is from https://developer.nvidia.com/teaching-kits-downloads

My local copy of what I'm using is in /parallel-class/GPU-Teaching-Kit-Accelerated-Computing

Today we did through module 2.

3   Changes this year

For students who've looked at last year's course, here are some upcoming changes.

  1. I'm dropping Stanford's parallel course. It's very nice but just too old.
  2. I'm adding material from Nvidia's developer site.
  3. I'll be presenting OpenACC.
  4. I'll think I'll recommend the PG compiler instead of g++.
  5. That requires recommending docker.

PAR Homework 3, due Thu 2020-02-06, noon

Rules

  1. Submit the answers to Gradescope.
  2. You may do homeworks in teams of 2 students. Create a gradescope team and make one submission with both names.
  3. For redundancy, at the top of your submitted homework write what it is and who you are. E.g., "Parallel Homework 2, 1/30/20, by Boris Badenov and Natasha Fatale".

Question

  1. The goal is to measure whether OpenMP actually makes matrix multiplication faster, with and w/o SIMD.

  2. You may use anything in /parallel-class/openmp that seems useful.

  3. Write a C++ program on parallel.ecse to initialize pseudorandomly and multiply two 100x100 float matrices. One possible initialization:

    a[i][j] = i*3 + (j*j)%5; b[i][j] = i*2 + (j*j)%7;

  4. (10 points) Report the elapsed time. Include the program listing.

  5. Add an OpenMP pragma to do the work in parallel.

  6. (10 points) Report the elapsed time, varying the number of threads thus: 1, 2, 4, 8, 16, 32, 64.

    What do you conclude?

  7. (5 points) Repeat that two more times to see how consistent the times are.

  8. (10 points) Modify the pragma to use SIMD.

    Report the elapsed time, varying the number of threads thus: 1, 2, 4, 8, 16, 32, 64.

    What do you conclude?

  9. (10 points) Compile and run your program with two different levels of compiler optimization: O1 and O3, reporting the elapsed time. Modify your program to prevent the optimizer from optimizing the program away to nothing. E.g., print a few values.

  10. (5 points) What do you conclude about everything?

Total: 40 pts.

PAR Syllabus

1   Catalog info

Title: ECSE-4740-01 Applied Parallel Computing for Engineers, CRN 94829
Semesters: Spring term annually
Credits: 3 credit hours
Time and place: Mon and Thurs noon-1:20pm, JONSSN 4107

2   Description

  1. This is intended to be a computer engineering course to provide students with knowledge and hands-on experience in developing applications software for affordable parallel processors. This course will mostly cover hardware that any lab can afford to purchase. It will cover the software that, in the prof's opinion, is the most useful. There will also be some theory.
  2. The target audiences are ECSE seniors and grads and others with comparable background who wish to develop parallel software.
  3. This course will have minimal overlap with parallel courses in Computer Science. We will not teach the IBM BlueGene, because it is so expensive, nor cloud computing and MPI, because most big data problems are in fact small enough to fit on our hardware.
  4. You may usefully take all the parallel courses at RPI.
  5. This unique features of this course are as follows:
    1. For 2/3 of the course, use of only affordable hardware that any lab might purchase, such as Nvidia GPUs. This is currently the most widely used and least expensive parallel platform.
    2. Emphasis on learning several programming packages, at the expense of theory. However you will learn a lot about parallel architecture.
  6. Hardware taught, with reasons:
    Multicore Intel Xeon:
      universally available and inexpensive, comparatively easy to program, powerful
    Nvidia GPU accelerator:
      widely available (Nvidia external graphics processors are on 1/3 of all PCs), very inexpensive, powerful, but harder to program. Good cards cost only a few hundred dollars.
    IBM quantum computer:
      It's new and hot and might some day be useful.
  7. Software that might be taught, with reasons:
    OpenMP C++ extension:
      widely used, easy to use if your algorithm is parallelizable, backend is primarily multicore Xeon but also GPUs.
    Thrust C++ functional programming library:
      FP is nice, hides low level details, backend can be any major parallel platform.
    MATLAB, Mathematica:
      easy to use parallelism for operations that they have implemented in parallel, etc.
    CUDA C++ extension and library for Nvidia:
      low level access to Nvidia GPUs.
  8. The techniques learned here will also be applicable to larger parallel machines -- numbers 1 and 2 on the top 500 list use NVIDIA GPUs. (Number 12 is a BlueGene.)
  9. Effectively programming these processors will require in-depth knowledge about parallel programming principles, as well as the parallelism models, communication models, and resource limitations of these processors.

3   Prerequisite

ECSE-2660 CANOS or equivalent, knowledge of C++.

4   Instructors

4.1   Professor

/files/wrf2013.jpg

W. Randolph Franklin. BSc (Toronto), AM, PhD (Harvard)

Office:

Jonsson Engineering Center (JEC) 6026

Phone:

+1 (518) 276-6077 (forwards)

Email:

frankwr@YOUKNOWTHEDOMAIN

Email is my preferred communication medium.

Sending from non-RPI accounts are fine, but please show your name, at least in the comment field. A subject prefix of #Prob is helpful. GPG encryption is fine.

Web:

https://wrf.ecse.rpi.edu/

A quick way to get there is to google RPIWRF.

Office hours:

After each lecture, usually as long as anyone wants to talk. Also by appointment.

Informal meetings:
 

If you would like to lunch with me, either individually or in a group, just mention it. We can then talk about most anything legal and ethical.

4.2   Teaching assistant

../files/cruz-photo.jpg

Elkin Cruz, cruzce@THEUSUALDOMAIN

Office hour: Tuesday 6-8pm in the flip flop Lounge.

5   Course websites

The homepage has lecture summaries, syllabus, homeworks, etc.

6   Reading material

6.1   Text

There is no required text, but the following inexpensive books may be used. I might mention others later.

  1. Sanders and Kandrot, CUDA by example. It gets excellent reviews, although it is several years old. Amazon has many options, including Kindle and renting hardcopies.
  2. Kirk and Hwu, 2nd edition, Programming massively parallel processors. It concentrates on CUDA.

One problem is that even recent books may be obsolete. For instance they may ignore the recent CUDA unified memory model, which simplifies CUDA programming at a performance cost. Even if the current edition of a book was published after unified memory was released, the author might not have updated the examples.

6.2   Web

There is a lot of free material on the web, which I'll reference class by class. Because web pages are vanish so often (really!), I may cache some locally. If interested, you might start here:

https://hpc.llnl.gov/training/tutorials

7   Computer systems used

7.1   parallel.ecse

This course will primarily use (remotely via ssh) parallel.ecse.rpi.edu.

Parallel has:

  1. dual 14-core Intel Xeon E5-2660 2.0GHz
  2. 256GB of DDR4-2133 ECC Reg memory
  3. Nvidia GPUs: #. Quadro RTX 8000 with 48GB memory, 16 TFLOPS, and 4608 CUDA cores. This can do real time ray tracing. #. GeForce GTX 1080 with 8GB memory and 2569 CUDA cores.
  4. Samsung Pro 850 1TB SSD
  5. WD Red 6TB 6GB/s hard drive
  6. CUDA 10.1
  7. OpenMP 4.5
  8. Thrust
  9. Ubuntu 19.10

Material for the class is stored in /parallel-class/ .

7.2   Amazon EC2

We might also use a parallel virtual machine on the Amazon EC2. If so, you will be expected to establish an account. I expect the usage to be in the free category.

7.3   Piazza

Piazza will be available for discussion and questions.

7.4   Gradescope

Gradescope will be used for you to submit homeworks and for us to distribute grades.

The entry code for this course is 9DYRB2.

Please add yourself.

8   Assessment measures, i.e., grades

  1. There will be no exams.
  2. Each student will make 2 or 3 in-class presentations summarizing some relevant topic.
  3. There will be a term project.

8.1   Homeworks

There will be some homeworks.

You may do homeworks in teams of 2 students. Create a gradescope team and make one submission with both names.

8.2   Term project

  1. For the latter part of the course, most of your homework time will be spent on a term project.

  2. You are encouraged do it in teams of up to 3 people. A team of 3 people would be expected to do twice as much work as 1 person.

  3. You may combine this with work for another course, provided that both courses know about this and agree. I always agree.

  4. If you are a grad student, you may combine this with your research, if your prof agrees, and you tell me.

  5. You may build on existing work, either your own or others'. You have to say what's new, and have the right to use the other work. E.g., using any GPLed code or any code on my website is automatically allowable (because of my Creative Commons licence).

  6. You will implement, demonstrate, and document something vaguely related to parallel computing.

  7. Deliverables:

    1. An implementation showing parallel computing.
    2. An extended abstract or paper on your project, written up like a paper. You should follow the style guide for some major conference (I don't care which, but can point you to one).
    3. A more detailed manual, showing how to use it.
    4. A 2-minute project proposal given to the class around the middle of the semester.
    5. A 10-minute project presentation and demo given to the class in the last week.
    6. Some progress reports.
    7. A write-up uploaded on the last class day. This will contain an academic paper, code and perhaps video or user manual.
  8. Size

    It's impossible to specify how many lines of code makes a good term project. E.g., I take pride in writing code that is can be simultaneously shorter, more robust, and faster than some others. See my 8-line program for testing whether a point is in a polygon: Pnpoly.

    According to Big Blues, when Bill Gates was collaborating with around 1980, he once rewrote a code fragment to be shorter. However, according to the IBM metric, number of lines of code produced, he had just caused that unit to officially do negative work.

9   Early warning system (EWS)

As required by the Provost, we may post notes about you to EWS, for example, if you're having trouble doing homeworks on time, or miss an exam. E.g., if you tell me that you had to miss a class because of family problems, then I may forward that information to the Dean of Students office.

10   Academic integrity

See the Student Handbook for the general policy. The summary is that students and faculty have to trust each other. After you graduate, your most important possession will be your reputation.

Specifics for this course are as follows.

  1. You may collaborate on homeworks, but each team of 1 or 2 people must write up the solution separately (one writeup per team) using their own words. We willingly give hints to anyone who asks.
  2. The penalty for two teams handing in identical work is a zero for both.
  3. You may collaborate in teams of up to 3 people for the term project.
  4. You may get help from anyone for the term project. You may build on a previous project, either your own or someone else's. However you must describe and acknowledge any other work you use, and have the other person's permission, which may be implicit. E.g., my web site gives a blanket permission to use it for nonprofit research or teaching. You must add something creative to the previous work. You must write up the project on your own.
  5. However, writing assistance from the Writing Center and similar sources in allowed, if you acknowledge it.
  6. The penalty for plagiarism is a zero grade.
  7. Cheating will be reported to the Dean of Students Office.

11   Student feedback

Since it's my desire to give you the best possible course in a topic I enjoy teaching, I welcome feedback during (and after) the semester. You may tell me or write me, or contact a third party, such as Prof James Lu, the ECSE undergrad head, or Prof John Wen, the ECSE Dept head.

PAR Class 3, Thu 2020-01-23

1   Homework 2

is online, due in a week.

2   Student talks next week

This is homework 1.

Having talks today is too rushed, so let's have all the talks next week (unless anyone wants to talk today).

As of 1/21, 10 people have picked a topic. I assigned them all to talk on Thur 1/30. The other people have been assigned to talk on Mon 1/27.

Grad students who haven't registered for a reading class and who also haven't doodled are also not listed. Add yourselves to Mon.

For privacy purposes, I've abbreved the names.

Monday speakers: please tell me your topics.

If anyone is part of a group, please tell me.

If any Thursday speaker would like to speak Mon, please tell me. You'll get first choice for dates on the next presentation.

  1. Mon
    1. Hayle
    2. JohnF
    3. Misha
    4. RossD
  2. Thu
    1. Alexa, Kevin
    2. Camer
    3. Chris
    4. Clara
    5. David
    6. Emily, Savan
    7. Eliza
    8. Garet
    9. Matth, Skyla
    10. MikeM
    11. Zhepe

3   parallel.ecse

The machine is parallel.ecse.rpi.edu . You must be on campus or use the VPN to connect. Connect with ssh.

I've created accounts for everyone in ECSE-4740 but not assigned passwords (and so you cannot login). In class today I'll let you type in a password. I'll create accounts for the reading students.

Its accounts are completely separate from RCS; I used the same userid for convenience. Changing your password on parallel does not affect your RCS password, and vv.

4   ssh, afs, zfs

  1. I recommend that you create key pairs to connect to parallel w/o typing your password each time.

  2. To avoid retyping your ssh private key passphrase in the same shell, do this

    ssh-add

  3. One advantage of ssh is that you can mount your parallel directory on your local machine. In the files browser on my laptop, I connect to the server sftp://parallel.ecse.rpi.edu . Any other program to mount network shares would work as well.

    Where the share is actually mounted varies. On my laptop, it's here: /var/run/user/1000/gvfs/sftp:host=parallel.ecse.rpi.edu,user=wrf

    1000 is my uid on my laptop. Yours is not 1000.

    As with any network mount, fancy filesystem things like attributes, simultaneous reading and writing from different machines, etc., probably won't work.

  4. With ssh, you can also copy files back and forth w/o mounting or typing passwords:

    1. scp localfile parallel.ecse.rpi.edu:
    2. scp -r localdir parallel.ecse.rpi.edu:
    3. scp parallel.ecse.rpi.edu:remotefile .

    It even does filename completion on remote files.

  5. You can also run single commands:

    ssh parallel.ecse.rpi.edu hostname

  6. In emacs, use tramp mode: Access file as /HOST:/FILE

  7. On parallel, most filesystems use zfs.

    1. Files are transparently compressed, so there's no need to explicitly use gzip etc.
    2. Filesystems are automatically snapshotted, so you can often recover accidentally deleted or changed files. Look under FSROOT /.zfs/snapshot/

5   OpenMP

  1. Versions: OpenMP is a living project, that is being updated every few years.

    1. There is a lot of free online documentation, examples, and tutorials.
    2. New features are regularly added, such as support for GPU backends.
    3. However the documentation and implementations lags.
    4. In my course, I'll use obsolete documentation when it's good enough. It's all still correct and fine for most applications.
    5. Then I'll present recent some additions.
  2. We'll review some examples running on parallel, at /parallel-class/openmp/rpi/ .

  3. Now that we've seen some examples, look at the LLNL tutorial. https://computing.llnl.gov/tutorials/openMP/

  4. We'll see some more examples running on parallel, at /parallel-class/openmp/rpi

  5. We saw that running even a short OpenMP program could be unpredictable. The reason for that was a big lesson.

    There are no guarantees about the scheduling of the various threads. There are no guarantees about fairness of resource allocation between the threads. Perhaps thread 0 finishes before thread 1 starts. Perhaps thread 1 finishes before thread 2 starts. Perhaps thread 0 executes 3 machine instructions, then thread 1 executes 1 instruction, then thread 0 executes 100 more, etc. Each time the process runs, something different may happen. One thing may happen almost all the time, to trick you.

    This happened during the first space shuttle launch in 1981. A 1-in-70 chance event prevented the computers from synchonizing. This had been observed once before during testing. However when they couldn't get it to happen again, they ignored it.

    This interlacing of different threads can happen at the machine instruction level. The C statement K=K+3 can translate into the machine instructions

    LOAD K; ADD 3; STORE K.

    Let's color the threads red and blue.

    If the threads interlace thus:

    LOAD K; ADD 3; STORE K; LOAD K; ADD 3; STORE K

    then K increases by 6. If they interlace thus:

    LOAD K; ADD 3; LOAD K; ADD 3; STORE K; STORE K;

    then K increases by 3.

  6. This can be really hard to debug, particularly when you don't know where this is happening.

    One solution is to serialize the offending code, so that only one thread executes it at a time. The limit would be to serialize the whole program and not to use parallel processing.

  7. OpenMP has several mechanisms to help.

  8. A critical pragma serializes the following block. There are two considerations.

    1. You lose the benefits of parallelization on that block.
    2. There is an overhead to set up a critical block that I estimate might be 100,000 instructions.
  9. An atomic pragma serializes one short C statement, which must be one of a small set of allowed operations, such as increment. It matches certain atomic machine instructions, like test-and-set. The overhead is much smaller.

  10. If every thread is summing into a common total variable, the reduction pragma causes each thread to sum into a private subtotal, and then sum the subtotals. This is very fast.

  11. Another lesson is that sometimes you can check your program's correctness with an independent computation. For the trivial example of summing \(i^2\), use the formula

    \(\sum_{i=1}^N i^2 = \frac{N(N+1)(2N+1)}{6}\).

    There is a lot of useful algebra if you have the time to learn it. I, ahem, learned this formula in high school.

  12. Another lesson is that even when the program gives the same answer every time, it might still be consistently wrong.

  13. Another is that just including OpenMP facilities, like -fopenmp, into your program slows it down even if you don't use them.

  14. Another is that the only meaningful time metric is elapsed real time. One reason that CPU time is meaningless is the OpenMP sometimes pauses a thread's progress by making it do a CPU-bound loop. (That is also a common technique in HW.)

  15. Also note that CPU times can vary considerably with successive executions.

  16. Also, using too many threads might increase the real time.

  17. Finally, floating point numbers have their own problems. They are an approximation of the mathematical concept called the real number field. That is defined by 11 axioms that state obvious properties, like

    A+B=B+A (commutativity) and

    A+(B+C)=(A+B+C) (associativity).

    This is covered in courses on modern algebra or abstract algebra.

    The problem is that most of these are violated, at least somewhat, with floats. E.g.,

    \(\left(10^{20}-10^{20}\right)+1=0+1=1\) but

    \(10^{20}+\left(-10^{20}+1\right)=10^{20}-10^{20}=0\).

    Therefore when threads execute in a different order, floating results might be different.

    There is no perfect solution, though using double is a start.

    1. On modern CPUs, double is just as fast as float.

    2. However it's slower on GPUs.

      How much slower can vary. Nvidia's Maxwell line spent very little real estate on double precision, so it was very slow. In contrast, Maxwell added a half-precision float, for implementing neural nets. Apparently neural nets use very few significant digits.

      Nvidia's newer Pascal line reverted this design choice and spends more real estate on implementing double. parallel.ecse's GPU is Pascal.

      Nvidia's Volta generation also does doubles well;

    3. It also requires moving twice the data, and data movement is often more important than CPU time.

    The large field of numerical analysis is devoted to finding solutions, with more robust and stable algorithms.

    Summing an array by first sorting, and then summing the absolutely smaller elements first is one technique. Inverting a matrix by pivoting on the absolutely largest element, instead of on \(a_{11}\) is another.

  18. Another nice, albeit obsolescent and incomplete, ref: Wikibooks OpenMP.

  19. Its tasks examples are interesting.

  20. OpenMP tasks

    1. While inside a pragma parallel, you queue up lots of tasks - they're executed as threads are available.

    2. My example is tasks.cc with some variants.

    3. taskfib.cc is modified from an example in the OpenMP spec.

      1. It shows how tasks can recursively spawn more tasks.

      2. This is only an example; you would never implement fibonacci that way. (The fastest way is the following closed form. In spite of the sqrts, the expression always gives an integer. )

        \(F_n = \frac{\left( \frac{1+\sqrt{5}}{2} \right) ^n - \left( \frac{1-\sqrt{5}}{2} \right) ^n }{\sqrt{5}}\)

      3. Spawning a task is expensive; we can calculate the cost.

  21. stacksize.cc - get and set stack size. Can also do ulimit -s.

  22. omps.cc - read assorted OMP variables.

  23. Since I/O is not thread-safe, in hello_single_barrier.cc it has to be protected by a critical and also followed by a barrier.

  24. OpenMP sections - my example is sections.cc with some variants.

    1. Note my cool way to print an expression's name followed by its value.
    2. Note the 3 required levels of pragmas: parallel, sections, section.
    3. The assignment of sections to threads is nondeterministic.
    4. IMNSHO, OpenMP considerably easier than pthreads, fork, etc.
  25. http://stackoverflow.com/questions/13788638/difference-between-section-and-task-openmp

PAR Homework 2, Thu 2020-01-23

Rules

  1. Due next Thurs, 2020-01-30, noon.
  2. Submit the answers to Gradescope.
  3. You may do homeworks in teams of 2 students. Create a gradescope team and make one submission with both names.
  4. For redundancy, at the top of your submitted homework write what it is and who you are. E.g., "Parallel Homework 2, 1/30/20, by Boris Badenov and Natasha Fatale".

Questions

Each is 5 points.

  1. Why is one CUDA core less powerful than one Intel Xeon core?
  2. If 10% of a program cannot be parallelized, then what is the max speedup even with infinite parallelism?
  3. "For short running parallel programs, there can actually be a decrease in performance compared to a similar serial implementation.". Why?
  4. What is the difference between strong scaling and weak scaling?
  5. What is cache coherency?
  6. Define "embarrassingly parallel".
  7. How many CUDA cores does the RTX 8000 have?
  8. Why have machine cycle speeds stopped increasing?
  9. Give an advantage and a disadvantage of shared memory versus distributed memory for parallel computation.
  10. In OpenMP, what's the difference between ATOMIC and CRITICAL?

Total: 50 pts.

PAR Class 2, Thu 2020-01-16

2   Student talks - 1st set

  1. Go to

https://doodle.com/poll/68axuciyyp3avwz5. Pick a topic by entering your name and rcsid (because sometimes students have similar names and sometimes students use different names from what's on the classlist). The topics are:

  1. Describe the fastest 2 computers on the top500 list. https://www.top500.org/lists/2018/11/
  2. Describe computers 3 and 4 on top500.
  3. Describe computers 5 and 6 on top500.
  4. Describe the Blue Gene.
  5. Summarize python's parallel capabilities.
  6. Summarize Matlab's parallel capabilities.
  7. Summarize Mathematica's parallel capabilities.
  8. Summarize MPI.
  9. Describe an application where physics needs/uses parallel computing.
  10. Describe an application where astronomy needs/uses parallel computing.
  11. Describe an application where biology needs/uses parallel computing.
  12. Describe an application where astronomy needs/uses parallel computing.
  13. Give an application where machine learning needs/uses parallel computing.
  14. Give an application where computational fluid dynamics needs/uses parallel computing.
  15. Summarize OpenACC.
  16. Summarize pthreads.
  17. More topics TBA.
  18. Other related topic of your choice. Tell me and I'll add it to the list.
  1. Note that any topic can be picked at most once.
  2. Two students may work together to present one talk.
  3. Prepare and give 5-10 minute talk next Thurs 1/23 or Mon 1/27 or Thurs 1/30. We'll spread the talks out evenly. A team would jointly give one 5-10 minute talk.

3   parallel.ecse

Its accounts are completely separate from RCS; I will use the same userid for convenience. Changing your password on parallel does not affect your RCS password, and vv.

4   OpenMP

  1. We'll see some examples running on parallel, at /parallel-class/openmp/rpi

  2. We saw that running even a short OpenMP program could be unpredictable. The reason for that was a big lesson.

    There are no guarantees about the scheduling of the various threads. There are no guarantees about fairness of resource allocation between the threads. Perhaps thread 0 finishes before thread 1 starts. Perhaps thread 1 finishes before thread 2 starts. Perhaps thread 0 executes 3 machine instructions, then thread 1 executes 1 instruction, then thread 0 executes 100 more, etc. Each time the process runs, something different may happen. One thing may happen almost all the time, to trick you.

PAR Class 1, Mon 2020-01-13

1   Material

  1. Read the syllabus.
  2. Read https://computing.llnl.gov/tutorials/parallel_comp/ for an intro to parallel computing.
  3. Some points:
    1. Parallel computing is decades old; there were commercial machines in the 1980s. I directed two PhD theses in parallel geometry then. However, then, clocks speeds were increasing so serial machines were more interesting.
    2. Now: physics limits to processor speed.
    3. History of Nvidia.
      1. Curtis Priem had designed graphics HW for both IBM and Sun Microsystems. (For awhile Sun was THE Unix workstation company. They used open standards and had the best price / performance.)
      2. Nvidia designed gaming graphics accelerators...
      3. that just happened to be parallel coprocessors...
      4. that started to be used for nongraphics parallel processing because of their value.
      5. Nvidia noticed that and added more capability, e.g., double precision IEEE floats, to serve that market.
      6. Currently, some of the highest performance Nvidia boards cannot even do graphics because they don't have video out ports.
    4. Intel CPUs vs Nvidia CUDA cores.
    5. Advantages and disadvantages of shared memory.
    6. OpenMP vs CUDA.
    7. Rate-limiting cost usually I/O not computation.
  4. Think about these questions.
    1. Why have machine cycle speeds stopped increasing?
    2. What architectures do the top 3 machines on the Top 500 list use?
    3. Which one of the following 4 choices are most GPUs: SISD, SIMD, MISD, MIMD.
    4. Which one of the following 4 choices are most current multicore CPUs: SISD, SIMD, MISD, MIMD.
    5. Per Amdahl's law, if a program is 10% sequential and 90% parallelizable, what is the max speed up that can be obtained with an infinite number of parallel processors?

2   Recently obsoleted parallel tech

  1. Intel Xeon Phi
  2. IBM BlueGene

3   Computer

  1. parallel.ecse accounts
    1. I'll set yours soon.
    2. Play with them. I recomend connecting with ssh.

4   My research

I do parallel geometry algorithms on large problems for CAD and GIS. See my home page. If this is interesting, talk to me. Maybe you can do something that leads to a jointly-authored paper.

PAR Grad Syllabus

1   Catalog info

Title: ECSE-6xxx Independent study: Parallel, GPU, quantum comput.
Semesters: Spring, on demand
Credits: 3 credit hours
Time and place: Mon and Thurs noon-1:20pm, JONSSN 4107

2   Description

  1. This is graduate individual study course.
  2. This is intended to be a computer engineering course to provide students with knowledge and hands-on experience in developing applications software for affordable parallel processors. This course will mostly cover hardware that any lab can afford to purchase. It will cover the software that, in the prof's opinion, is the most useful. There will also be considerable theory.
  3. The target audience is ECSE grads and others with comparable background who wish to learn the theory and then to develop parallel software.
  4. This course will have minimal overlap with parallel courses in Computer Science. We will not teach the IBM BlueGene, because it is so expensive, nor cloud computing and MPI, because most big data problems are in fact small enough to fit on our hardware.
  5. You may usefully take all the parallel courses at RPI.
  6. This unique features of this course are as follows:
    1. For 2/3 of the course, use of only affordable hardware that any lab might purchase, such as Nvidia GPUs. This is currently the most widely used and least expensive parallel platform.
    2. Emphasis on learning several programming packages, at the expense of theory. However you will learn a lot about parallel architecture.
  7. Hardware taught, with reasons:
    Multicore Intel Xeon:
      universally available and inexpensive, comparatively easy to program, powerful
    Nvidia GPU accelerator:
      widely available (Nvidia external graphics processors are on 1/3 of all PCs), very inexpensive, powerful, but harder to program. Good cards cost only a few hundred dollars.
    IBM quantum computer:
      It's new and hot and might some day be useful.
  8. Software that might be taught, with reasons:
    OpenMP C++ extension:
      widely used, easy to use if your algorithm is parallelizable, backend is primarily multicore Xeon but also GPUs.
    Thrust C++ functional programming library:
      FP is nice, hides low level details, backend can be any major parallel platform.
    MATLAB, Mathematica:
      easy to use parallelism for operations that they have implemented in parallel, etc.
    CUDA C++ extension and library for Nvidia:
      low level access to Nvidia GPUs.
  9. The techniques learned here will also be applicable to larger parallel machines -- numbers 1 and 2 on the top 500 list use NVIDIA GPUs. (Number 12 is a BlueGene.)
  10. Effectively programming these processors will require in-depth knowledge about parallel programming principles, as well as the parallelism models, communication models, and resource limitations of these processors.

3   Prerequisite

ECSE-2660 CANOS or equivalent, knowledge of C++.

4   Instructors

4.1   Professor

W. Randolph Franklin. BSc (Toronto), AM, PhD (Harvard)

Office:

Jonsson Engineering Center (JEC) 6026

Phone:

+1 (518) 276-6077 (forwards)

Email:

frankwr@YOUKNOWTHEDOMAIN

Email is my preferred communication medium.

Sending from non-RPI accounts are fine, but please show your name, at least in the comment field. A subject prefix of #Prob is helpful. GPG encryption is fine.

Web:

https://wrf.ecse.rpi.edu/

A quick way to get there is to google RPIWRF.

Office hours:

After each lecture, usually as long as anyone wants to talk. Also by appointment.

Informal meetings:
 

If you would like to lunch with me, either individually or in a group, just mention it. We can then talk about most anything legal and ethical.

4.2   Teaching assistant

Elkin Cruz, cruzce@THEUSUALDOMAIN

Office hour: TBA

5   Course websites

The homepage has lecture summaries, syllabus, homeworks, etc.

6   Reading material

6.1   Text

There is no required text, but the following inexpensive books may be used. I might mention others later.

  1. Sanders and Kandrot, CUDA by example. It gets excellent reviews, although it is several years old. Amazon has many options, including Kindle and renting hardcopies.
  2. Kirk and Hwu, 2nd edition, Programming massively parallel processors. It concentrates on CUDA.

One problem is that even recent books may be obsolete. For instance they may ignore the recent CUDA unified memory model, which simplifies CUDA programming at a performance cost. Even if the current edition of a book was published after unified memory was released, the author might not have updated the examples.

6.2   Web

There is a lot of free material on the web, which I'll reference class by class. Because web pages are vanish so often (really!), I may cache some locally. If interested, you might start here:

https://hpc.llnl.gov/training/tutorials

7   Computer systems used

7.1   parallel.ecse

This course will primarily use (remotely via ssh) parallel.ecse.rpi.edu.

Parallel has:

  1. dual 14-core Intel Xeon E5-2660 2.0GHz
  2. 256GB of DDR4-2133 ECC Reg memory
  3. Nvidia GPUs: #. Quadro RTX 8000 with 48GB memory, 16 TFLOPS, and 4608 CUDA cores. This can do real time ray tracing. #. GeForce GTX 1080 with 8GB memory and 2569 CUDA cores.
  4. Samsung Pro 850 1TB SSD
  5. WD Red 6TB 6GB/s hard drive
  6. CUDA 10.1
  7. OpenMP 4.5
  8. Thrust
  9. Ubuntu 19.10

Material for the class is stored in /parallel-class/ .

7.2   Amazon EC2

We might also use a parallel virtual machine on the Amazon EC2. If so, you will be expected to establish an account. I expect the usage to be in the free category.

7.3   Piazza

Piazza will be available for discussion and questions.

7.4   Gradescope

Gradescope will be used for you to submit homeworks and for us to distribute grades.

The entry code for this course is 9DYRB2.

Please add yourself.

8   Assessment measures, i.e., grades

  1. There will be no exams.
  2. There might be some homeworks.
  3. Each student will make 2 or 3 in-class presentations summarizing some relevant topic.
  4. There will be a term project that will include a major research paper.
  5. A blog will be required.

8.1   Research blog

Students will be required to perform individual research into parallel computing principles and to record their findings as weekly entries in a personal blog, a sort of online lab book.

Possible platforms include:

  1. Mathmatica notebook
  2. Jupyter book
  3. Google doc
  4. icloud doc

8.2   Term project

  1. For the latter part of the course, most of your homework time will be spent on a term project.

  2. You are encouraged do it in teams of up to 3 people. A team of 3 people would be expected to do twice as much work as 1 person.

  3. You may combine this with work for another course, provided that both courses know about this and agree. I always agree.

  4. If you are a grad student, you may combine this with your research, if your prof agrees, and you tell me.

  5. You may build on existing work, either your own or others'. You have to say what's new, and have the right to use the other work. E.g., using any GPLed code or any code on my website is automatically allowable (because of my Creative Commons licence).

  6. You will implement, demonstrate, and document something vaguely related to parallel computing.

  7. Deliverables:

    1. An implementation showing parallel computing.
    2. A major research paper on your project. You should follow the style guide for some major conference (I don't care which, but can point you to one).
    3. A more detailed manual, showing how to use it.
    4. A 2-minute project proposal given to the class around the middle of the semester.
    5. A 10-minute project presentation and demo given to the class in the last week.
    6. Some progress reports.
    7. A write-up uploaded on the last class day. This will contain an academic paper, code and perhaps video or user manual.
  8. Size

    It's impossible to specify how many lines of code makes a good term project. E.g., I take pride in writing code that is can be simultaneously shorter, more robust, and faster than some others. See my 8-line program for testing whether a point is in a polygon: Pnpoly.

    According to Big Blues, when Bill Gates was collaborating with around 1980, he once rewrote a code fragment to be shorter. However, according to the IBM metric, number of lines of code produced, he had just caused that unit to officially do negative work.

9   Early warning system (EWS)

As required by the Provost, we may post notes about you to EWS, for example, if you're having trouble doing homeworks on time, or miss an exam. E.g., if you tell me that you had to miss a class because of family problems, then I may forward that information to the Dean of Students office.

10   Academic integrity

See the Student Handbook for the general policy. The summary is that students and faculty have to trust each other. After you graduate, your most important possession will be your reputation.

Specifics for this course are as follows.

  1. You may collaborate on homeworks, but each team of 1 or 2 people must write up the solution separately (one writeup per team) using their own words. We willingly give hints to anyone who asks.
  2. The penalty for two teams handing in identical work is a zero for both.
  3. You may collaborate in teams of up to 3 people for the term project.
  4. You may get help from anyone for the term project. You may build on a previous project, either your own or someone else's. However you must describe and acknowledge any other work you use, and have the other person's permission, which may be implicit. E.g., my web site gives a blanket permission to use it for nonprofit research or teaching. You must add something creative to the previous work. You must write up the project on your own.
  5. However, writing assistance from the Writing Center and similar sources in allowed, if you acknowledge it.
  6. The penalty for plagiarism is a zero grade.
  7. Cheating will be reported to the Dean of Students Office.

11   Student feedback

Since it's my desire to give you the best possible course in a topic I enjoy teaching, I welcome feedback during (and after) the semester. You may tell me or write me, or contact a third party, such as Prof James Lu, the ECSE undergrad head, or Prof John Wen, the ECSE Dept head.