OpenMP omp_get_schedule() segmentation fault

So basically this is what I am doing:

1
2
3
omp_sched_t *kind;
int *modifier;
omp_get_schedule(kind,modifier);


and I am getting segmentation fault. Compiled with -fopenmp flag

any ideas??
closed account (j3Rz8vqX)
Problem is likely elsewhere...

segmentation fault, confirms that you have gone out of bounds somewhere.

Check your loops.

Look at the indexes and the flow/behavior of the index value.

Good luck.
I have isolated the problem in those three lines, in a new program containing the main ,defines and those 3 lines. commenting the function wont lead to segfault.
thanks for ur answer:)
So basically this is what I am doing:

1
2
3
omp_sched_t *kind;
int *modifier;
omp_get_schedule(kind,modifier);


So, basically you're feeding omp_get_schedule junk and wondering why it doesn't work? Neither kind nor modifier contain valid memory addresses, so when they're dereferenced in omp_get_schedule bad things happen.
Last edited on
I am guessing I need 2 malloc?

1
2
3
omp_sched_t *kind =malloc(sizeof(omp_sched_t));
int *modifier = malloc(sizeof (int));


It has been some time since I played with C, I thought declaring as a pointer was enough to have memory booked.

Thanks, I will try and if it works I'll mark it as solved ;)
Last edited on
I am guessing I need 2 malloc?

That's one way to do things, but not really recommended.

1
2
3
    omp_sched_t schedule_type ;
    int chunk_size ;
    omp_get_schedule(&schedule_type, &chunk_size);

Topic archived. No new replies allowed.