resource on Openmp and class Object c++

General OpenMP discussion

resource on Openmp and class Object c++

Postby open_coder » Tue Feb 12, 2019 9:59 pm

Could anyone suggest me a good resource of implementation of Openmp using Class Object in c++ ?

I am creating an object and try to call a same function with different parameter, with different threads. But some times its giving correct result, some time " segmentation fault " and some time " double free or corruption (fasttop): 0x00007f5d980cf8e0 *** ".
I think its behavior depends on order of object created and deleted inside parallel region.

Anyone please suggest me a better solution. Below is part of my code.


class Object{
Queue Q;

int Naive_search(int src, int dest, int d_time, int id);
int Forward_search(int src, int dest, int d_time, int id);
int Trace_search(int src, int dest, int d_time, int a_time, int id);
int Impromptu_rendezous(int f_id, int t_id, int node, int dest);
void Show_path(int dest, int id);
void Show_r_path(int dest, int id);
void Show_dist(int src);
void Show_flat_times(void);

Object(){ Q = Queue(); }
Object(const Object &n){ Q = Queue(n.Q); }
Object obj;


#pragma omp parallel default(none) private(id, nth, a_time, min_time, f_stop, obj)\
firstprivate(LBT, UBT, last_time, counter, threshold, window_size, limit, d_time, src, dest)\
shared(min_trace, min_ford)
nth = omp_get_num_threads();
id = omp_get_thread_num();

if(id == 0){
min_ford = time_length;
min_ford = obj.Forward_search(src, dest, d_time, id);
a_time = LBT + id - 1;
min_time = obj.Trace_search(src, dest, d_time, a_time, id);
#pragma omp critical
min_trace = min(min_trace, min_time);
printf("src: %d depature at %d arrival dest: %d at %d (min_ford: %d, min_trace: %d)\n\n",
src, d_time, dest, min(min_trace, min_ford), min_ford, min_trace);
Posts: 9
Joined: Mon Oct 29, 2018 9:42 pm

Re: resource on Openmp and class Object c++

Postby MarkB » Tue Feb 19, 2019 8:18 am

You probably have a race condition inside the constructor or in one of the methods called inside the parallel region.
Posts: 775
Joined: Thu Jan 08, 2009 10:12 am
Location: EPCC, University of Edinburgh

Return to Using OpenMP

Who is online

Users browsing this forum: No registered users and 3 guests