Figure 8-6. Random number generation on GPU and CPU (factor = 10)
Now let’s consider a test series with a comparatively heavy workload. The largest random
number array is 400 MB in size:
In [ 111 ]: %%time
factor = 5000
cuda_times, cpu_times = time_comparsion(factor)
Out[111]: Bytes of largest array 400040000
CPU times: user 22 s, sys: 3.52 s, total: 25.5 s
Wall time: 25.4 s
For heavy workloads the GPU clearly shows its advantages, as Figure 8-7 impressively
illustrates:
In [ 112 ]: plot_results(cpu_times, cuda_times, factor)
Figure 8-7. Random number generation on GPU and CPU (factor = 5,000)