Skip to content

Conversation

@mattsinc
Copy link

@mattsinc mattsinc commented Apr 3, 2021

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).

Matt Sinclair added 4 commits April 3, 2021 16:13
ParticleFilter in Rodinia fails when run on the head of GPGPU-Sim
with a memory corruption.  Looking further into the failures with
valgrind, there were numerous uninitialized values in the arrays
that were being accessed subsequently, causing the memory
corruption error.  To resolve this, all mallocs have been changed
to callocs, which intiializes all locations to 0 and removes the
error.  From looking at the code, it appears these locations
were assumed to be 0 all along, so this fix does not affect any
functionality.
Print warning occurred because %d was used instead of %ld, this
commit fixes that.
Update all cudaThreadSynchronize calls to cudaDeviceSynchronize,
which has replaced it in more modern CUDA versions.
@mattsinc
Copy link
Author

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

@mkhairy mkhairy merged commit 52c11fb into accel-sim:release Apr 30, 2021
@mkhairy
Copy link
Contributor

mkhairy commented Apr 30, 2021

thanks @mattsinc

LAhmos pushed a commit to purdue-aalp/gpu-app-collection-public that referenced this pull request Jul 6, 2025
fix particlefilter so it can run in GPGPU-Sim
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants