accel-sim / gpu-app-collection

A repository where GPU applications are aggregated using a common build flow that supports multiple CUDA versions.
44 stars 32 forks source link

fix particlefilter so it can run in GPGPU-Sim #4

Closed mattsinc closed 3 years ago

mattsinc commented 3 years ago

The host-side mallocs in particlefilter trigger a malloc corruption that would seemingly random crop up. Interestingly, the malloc corruption would only happen when running GPGPU-Sim -- when run on the real GPU, it would run to completion as expected. Setup: Ubuntu 16.04, gcc 5.4, CUDA 9.1. Command line: ./particlefilter_float -x 128 -y 128 -z 10 -np 1000, Titan V config.

After running valgrind on the application (with and without GPGPU-Sim), I found that this corruption was happening because some of the locations in the host side arrays were not being initialized, but were subsequently being accessed and used to influence other mallocs. So, this effectively meant that the arrays had some garbage values certain locations were initialized to, and these values were corrupting subsequent mallocs.

My solution was to change all of the mallocs to callocs to force all locations to be 0 initially. It certainly seems like calloc is the right way to go for arrays like objxy, disk, I, and others -- all of them only initialize certain locations in subsequent calls to non-0 values if conditions are met, but all locations are accessed in guarding if statements -- so if they were initialized to garbage instead of 0, then they would be doing the wrong thing anyways.

In addition to this, I also fixed some various small warnings and tabs --> spaces issues in particlefilter (each a separate commit).

mattsinc commented 3 years ago

@mkhairy , @tgrogers : just a reminder to look at this.

mkhairy commented 3 years ago

thanks @mattsinc