fix particlefilter so it can run in GPGPU-Sim #4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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).