OpenMP parallel function calling on object iteration
up vote
0
down vote
favorite
I'm having problems parallelising the calling of a member function in a for loop. I only want to parallelise the iteration of objects, not the iteration of vectors within the called function.
This is how i call the parallel section, where particle_vector
is a vector of objects and build_state_pylist()
is a member function. state_vec
and state_pylist
are both object members.
#pragma omp parallel for
for (int i=0; i < n_sims; ++i) {
particle_vector[i].build_state_pylist();
}
build_state_pylist()
iterates through values of state_vec
, which is a std::vector of vectors. The contained values and appending them to state_pylist, a boost::python::list, which is a member of the object.
void Particle::build_state_pylist() {
for (auto sim_iter = state_vec.begin(); sim_iter != state_vec.end(); ++sim_iter) {
auto sim_vec = *sim_iter;
for (auto vec_iter= sim_vec.begin(); vec_iter!= sim_vec.end(); ++vec_iter) {
this->state_pylist.append(*vec_iter);
}
}
}
Since the each loop iteration is only accessing memory contained within each object I didn't think parallelising this section would be a problem. But I get this error:
double free or corruption (!prev)
and
(core dumped)
The loop works without parallelisation. Any help would be greatly appreciated!
c++ boost parallel-processing openmp
add a comment |
up vote
0
down vote
favorite
I'm having problems parallelising the calling of a member function in a for loop. I only want to parallelise the iteration of objects, not the iteration of vectors within the called function.
This is how i call the parallel section, where particle_vector
is a vector of objects and build_state_pylist()
is a member function. state_vec
and state_pylist
are both object members.
#pragma omp parallel for
for (int i=0; i < n_sims; ++i) {
particle_vector[i].build_state_pylist();
}
build_state_pylist()
iterates through values of state_vec
, which is a std::vector of vectors. The contained values and appending them to state_pylist, a boost::python::list, which is a member of the object.
void Particle::build_state_pylist() {
for (auto sim_iter = state_vec.begin(); sim_iter != state_vec.end(); ++sim_iter) {
auto sim_vec = *sim_iter;
for (auto vec_iter= sim_vec.begin(); vec_iter!= sim_vec.end(); ++vec_iter) {
this->state_pylist.append(*vec_iter);
}
}
}
Since the each loop iteration is only accessing memory contained within each object I didn't think parallelising this section would be a problem. But I get this error:
double free or corruption (!prev)
and
(core dumped)
The loop works without parallelisation. Any help would be greatly appreciated!
c++ boost parallel-processing openmp
2
This cannot be answered without seeing more code, the problem is likely somewhere deep inside. Are you 100% sure that there is no shared resource accessed by multiple threads withinParticle::build_state_pylist()
?
– Daniel Langr
Nov 8 at 11:46
1
Also, couldn't this issue be related to your problem: boost.python not supporting parallelism? See also the documentation: wiki.python.org/moin/boost.python/…
– Daniel Langr
Nov 8 at 11:51
WithinParticle::build_state_pylist()
, the resources being accessed arestate_vec
andstate_pylist
. Both of which are object members, so I'm not sure why they would be shared across threads. edit: I'll look into the boost parallel support!
– Behzad
Nov 8 at 11:55
It's difficult to answer your question without having a minimal example to reproduce the issue. If you didn't already, you could try tools like Clang's Thread Sanitizer to have more information on the eventual data race.
– Massimiliano
Nov 14 at 19:51
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm having problems parallelising the calling of a member function in a for loop. I only want to parallelise the iteration of objects, not the iteration of vectors within the called function.
This is how i call the parallel section, where particle_vector
is a vector of objects and build_state_pylist()
is a member function. state_vec
and state_pylist
are both object members.
#pragma omp parallel for
for (int i=0; i < n_sims; ++i) {
particle_vector[i].build_state_pylist();
}
build_state_pylist()
iterates through values of state_vec
, which is a std::vector of vectors. The contained values and appending them to state_pylist, a boost::python::list, which is a member of the object.
void Particle::build_state_pylist() {
for (auto sim_iter = state_vec.begin(); sim_iter != state_vec.end(); ++sim_iter) {
auto sim_vec = *sim_iter;
for (auto vec_iter= sim_vec.begin(); vec_iter!= sim_vec.end(); ++vec_iter) {
this->state_pylist.append(*vec_iter);
}
}
}
Since the each loop iteration is only accessing memory contained within each object I didn't think parallelising this section would be a problem. But I get this error:
double free or corruption (!prev)
and
(core dumped)
The loop works without parallelisation. Any help would be greatly appreciated!
c++ boost parallel-processing openmp
I'm having problems parallelising the calling of a member function in a for loop. I only want to parallelise the iteration of objects, not the iteration of vectors within the called function.
This is how i call the parallel section, where particle_vector
is a vector of objects and build_state_pylist()
is a member function. state_vec
and state_pylist
are both object members.
#pragma omp parallel for
for (int i=0; i < n_sims; ++i) {
particle_vector[i].build_state_pylist();
}
build_state_pylist()
iterates through values of state_vec
, which is a std::vector of vectors. The contained values and appending them to state_pylist, a boost::python::list, which is a member of the object.
void Particle::build_state_pylist() {
for (auto sim_iter = state_vec.begin(); sim_iter != state_vec.end(); ++sim_iter) {
auto sim_vec = *sim_iter;
for (auto vec_iter= sim_vec.begin(); vec_iter!= sim_vec.end(); ++vec_iter) {
this->state_pylist.append(*vec_iter);
}
}
}
Since the each loop iteration is only accessing memory contained within each object I didn't think parallelising this section would be a problem. But I get this error:
double free or corruption (!prev)
and
(core dumped)
The loop works without parallelisation. Any help would be greatly appreciated!
c++ boost parallel-processing openmp
c++ boost parallel-processing openmp
asked Nov 8 at 11:13
Behzad
5617
5617
2
This cannot be answered without seeing more code, the problem is likely somewhere deep inside. Are you 100% sure that there is no shared resource accessed by multiple threads withinParticle::build_state_pylist()
?
– Daniel Langr
Nov 8 at 11:46
1
Also, couldn't this issue be related to your problem: boost.python not supporting parallelism? See also the documentation: wiki.python.org/moin/boost.python/…
– Daniel Langr
Nov 8 at 11:51
WithinParticle::build_state_pylist()
, the resources being accessed arestate_vec
andstate_pylist
. Both of which are object members, so I'm not sure why they would be shared across threads. edit: I'll look into the boost parallel support!
– Behzad
Nov 8 at 11:55
It's difficult to answer your question without having a minimal example to reproduce the issue. If you didn't already, you could try tools like Clang's Thread Sanitizer to have more information on the eventual data race.
– Massimiliano
Nov 14 at 19:51
add a comment |
2
This cannot be answered without seeing more code, the problem is likely somewhere deep inside. Are you 100% sure that there is no shared resource accessed by multiple threads withinParticle::build_state_pylist()
?
– Daniel Langr
Nov 8 at 11:46
1
Also, couldn't this issue be related to your problem: boost.python not supporting parallelism? See also the documentation: wiki.python.org/moin/boost.python/…
– Daniel Langr
Nov 8 at 11:51
WithinParticle::build_state_pylist()
, the resources being accessed arestate_vec
andstate_pylist
. Both of which are object members, so I'm not sure why they would be shared across threads. edit: I'll look into the boost parallel support!
– Behzad
Nov 8 at 11:55
It's difficult to answer your question without having a minimal example to reproduce the issue. If you didn't already, you could try tools like Clang's Thread Sanitizer to have more information on the eventual data race.
– Massimiliano
Nov 14 at 19:51
2
2
This cannot be answered without seeing more code, the problem is likely somewhere deep inside. Are you 100% sure that there is no shared resource accessed by multiple threads within
Particle::build_state_pylist()
?– Daniel Langr
Nov 8 at 11:46
This cannot be answered without seeing more code, the problem is likely somewhere deep inside. Are you 100% sure that there is no shared resource accessed by multiple threads within
Particle::build_state_pylist()
?– Daniel Langr
Nov 8 at 11:46
1
1
Also, couldn't this issue be related to your problem: boost.python not supporting parallelism? See also the documentation: wiki.python.org/moin/boost.python/…
– Daniel Langr
Nov 8 at 11:51
Also, couldn't this issue be related to your problem: boost.python not supporting parallelism? See also the documentation: wiki.python.org/moin/boost.python/…
– Daniel Langr
Nov 8 at 11:51
Within
Particle::build_state_pylist()
, the resources being accessed are state_vec
and state_pylist
. Both of which are object members, so I'm not sure why they would be shared across threads. edit: I'll look into the boost parallel support!– Behzad
Nov 8 at 11:55
Within
Particle::build_state_pylist()
, the resources being accessed are state_vec
and state_pylist
. Both of which are object members, so I'm not sure why they would be shared across threads. edit: I'll look into the boost parallel support!– Behzad
Nov 8 at 11:55
It's difficult to answer your question without having a minimal example to reproduce the issue. If you didn't already, you could try tools like Clang's Thread Sanitizer to have more information on the eventual data race.
– Massimiliano
Nov 14 at 19:51
It's difficult to answer your question without having a minimal example to reproduce the issue. If you didn't already, you could try tools like Clang's Thread Sanitizer to have more information on the eventual data race.
– Massimiliano
Nov 14 at 19:51
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53206605%2fopenmp-parallel-function-calling-on-object-iteration%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
This cannot be answered without seeing more code, the problem is likely somewhere deep inside. Are you 100% sure that there is no shared resource accessed by multiple threads within
Particle::build_state_pylist()
?– Daniel Langr
Nov 8 at 11:46
1
Also, couldn't this issue be related to your problem: boost.python not supporting parallelism? See also the documentation: wiki.python.org/moin/boost.python/…
– Daniel Langr
Nov 8 at 11:51
Within
Particle::build_state_pylist()
, the resources being accessed arestate_vec
andstate_pylist
. Both of which are object members, so I'm not sure why they would be shared across threads. edit: I'll look into the boost parallel support!– Behzad
Nov 8 at 11:55
It's difficult to answer your question without having a minimal example to reproduce the issue. If you didn't already, you could try tools like Clang's Thread Sanitizer to have more information on the eventual data race.
– Massimiliano
Nov 14 at 19:51