This page was last updated: May 9, 2022
Note: The flip machines do not have GPU cards in them, so CUDA will not run there. If your own system has a GPU, you can use that. You can also use rabbit or the DGX machine, but please be good about sharing them.
Monte Carlo simulation is used to determine the range of outcomes for a series of parameters, each of which has a probability distribution showing how likely each option is to happen. In this project, you will take the Project #1 scenario and develop a CUDA-based Monte Carlo simulation of it, determining how likely a particular output is to happen. You will then take timing results and compare them with what you got with OpenMP in Project #1.
Use the same scenario from Project #1.
On both rabbit and the DGX system, here is a working Makefile:
CUDA_PATH = /usr/local/apps/cuda/cuda-10.1
CUDA_BIN_PATH = $(CUDA_PATH)/bin
CUDA_NVCC = $(CUDA_BIN_PATH)/nvcc
montecarlo: montecarlo.cu
$(CUDA_NVCC) -o montecarlo montecarlo.cu
You can (and should!) write scripts to run the benchmark combinations. If you want to pass in benchmark parameters, the -DNUMTRIALS=$t notation works fine in nvcc.
Before you use the DGX, do your development on the rabbit system. It is a lot friendlier because you don't have to run your program through a batch submission. you can take your final performance numbers on rabbit, but you will enjoy the numbers you get on the DGX more!
You can also take your benchmark numbers on your own machine.
If you are trying to run CUDA on your own Visual Studio system, make sure your machine has the CUDA toolkit installed. It is available here: https://developer.nvidia.com/cuda-downloads
This requires a special setup so that Visual Studio knows to run nvcc in the right place. See our CUDA noteset for instructions.
Here is the complete array-multiplication CUDA program we looked at in class: arrayMul.cu. As a first step, you might try getting on rabbit and compiling and running it to be sure you understand the process.
proj05.cu This code has both the old table of parameters and the new table listed in it. The line: #define PROJECT1 will turn on the old values. Changing it to: //#define PROJECT1 will turn on the new values. When you think your code is ready to go, try it with the old values and see if you get a correct probability of ~29%. If you don't, then something is wrong with your code.
Variable | Description | Minimum | Maximum |
---|---|---|---|
tx | Truck X starting location in feet | -10. | 10. |
txv | Truck X velocity in feet/second | 15. | 35. |
ty | Truck Y location in feet | 40. | 50. |
sv | Snowball overall velocity in feet/second | 5. | 30. |
theta | Snowball horizontal launch angle in degrees | 10. | 70. |
halflen | Truck half-length in feet | 15. | 30. |
Note: these are not the same numbers as we used before!
Feature | Points |
---|---|
Correct probability | 10 |
Monte Carlo performance table | 20 |
Graph of performance vs. NUMTRIALS with multiple curves of BLOCKSIZE | 25 |
Graph of performance vs. BLOCKSIZE with multiple curves of NUMTRIALS | 25 |
Commentary | 20 |
Potential Total | 100 |