JM

Table of Contents

Exercises

  1. In the Case Study we found that the hand-written mc_random_walk_kernel! kernel was slower than the fused broadcast version, mc_random_walk_fused!. Rewrite the kernel so that it matches (or beats) the fused version, benchmarking both after synchronize(get_backend(y_gpu)) and checking that the two still produce statistically equivalent results. Hints: pre-generate all normal deviates in a device array and have each kernel invocation consume them; it is also worth sweeping KernelAbstractions workgroup sizes rather than assuming that 256256 is optimal.

  2. Take some of your existing code and port it to the GPU using the inbuilt array operations, then write a custom KernelAbstractions.@kernel for the more complicated operations. Verify correctness by comparing against the CPU result with isapprox, and benchmark both versions after synchronize(get_backend(array)) to check that moving to the GPU was actually worthwhile once the host-to-device copies are counted.