Comments (7)
A further checking indicates other similar bugs relating to the use of malloc.
from susy.
Thanks very much for the report! I may not have a chance to address it until I get back from a conference on 15 January.
In the meantime, I'm curious what compiler you're using, as obviously this isn't an issue we have encountered with any of those we use (mainly various versions of gcc, with either mpich2 and mvapich MPI implementations).
In a standards-compliant compiler I would expect the two possibilities you write in each case to be handled identically. The style currently in the code (dereferencing the pointer rather than repeating the type) is typically advocated in order to improve the maintainability of the code. See here for one example, which also suggests moving the sizeof to the front. That may be worth testing, especially considering the apparent integer arithmetic issue suggested by your other report. This should look something like
Twist_Fermion **src = malloc(sizeof **src * Norder);
and so on.
from susy.
Thank you for your reply. Moving the sizeof to the front is good. But I am worried that the coding style as below
Twist_Fermion **src = malloc(sizeof **src * Norder);
still has a bug in it. As src is a pointer to data type "Twist_Fermion *". When we do the malloc(), we hope to malloc a memory space of size "sizeof (*src) * Norder" instead of "sizeof (**src) * Norder" --- the former indicates Norder elements of data type "Twist_Fermion *" while the latter indicates Norder elements of data type "Twist_Fermion".
Btw, I am actually working on a project that aims to provide an automated testing tool for MPI programs. I use this program as a target to do some analysis and happen to find these bugs. I don't know well enough the program actually.
from susy.
Norder elements of data type "Twist_Fermion *" is exactly what we want for the RHMC algorithm, which involves Norder
source vectors, each of which is malloc'd with sites_on_node
elements a few lines further down. In the end src
is an array of Norder
pointers to arrays of sites_on_node
Twist_Fermions, with the individual structs accessed via src[N][i]
for the components of source vector N
associated with lattice site i
.
Anyway, it sounds like moving the sizeof to the front resolves the problem you encountered, so I quickly did that in commit e2d120b and will close this issue as well. Feel free to reopen if problems remain.
from susy.
If we want to add "Twist_Fermion *", should we use
Twist_Fermion **src = malloc(sizeof *src * Norder);
instead of
Twist_Fermion **src = malloc(sizeof **src * Norder);
?
from susy.
Okay, I'm finding the dereferencing hard to parse, so I scrapped it for the sake of readability. Commit 53adcdc essentially implements your original suggestion. Valgrind seems happy, at least in serial.
from susy.
That's great. To be honest, I don't know much about physics, and thus just look the program from the perspective of the programmer.
Thank you for your work:)
from susy.
Related Issues (11)
- Update to PRIMME2 or PRIMME3
- Bug Report: Division by Zero HOT 5
- Report more malloc data
- Input methods
- Move some operations out of loops
- Mixed-precision multi-shift solver
- Convert library_util.c to actual library utils
- Multi-shift solver for stochastic mode number?
- Test truncation HOT 1
- More code reuse HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from susy.