0

I am new to openMP and I was wondering if someone can review my approach.

Problem: I have sequential arrival of data from a device which has data from many sensors. I think I can parallely process analytics on each data packet to increase resolution.

Solution I thought of is as follows - but it ends up in deadlocks

This is pseudocode - so please ignore the syntax

TOTAL_SENSORS = 1000 omp_lock_t sensor_locks[TOTAL_SENSORS] #pragma omp parallel #pragma omp for for(int i=0;i<TOTAL_SENSORS;i++) { omp_init_lock(&sensor_locks[i]); } #pragma omp parallel #pragma omp single while (! end_of_data){ for sensor_data in packed_data.iterator() { if sensor_data.sensor_type = 'A' { #omp task firstprivate(sensor_data) { omp_set_lock(&sensor_locks[sensor_data.sensor_id]); compute_analytics_type_A(sensor_data) omp_unset_lock(&sensor_locks[sensor_data.sensor_id]); } } else { #omp task firstprivate(sensor_data) { omp_set_lock(&sensor_locks[sensor_data.sensor_id]); compute_analytics_type_B(sensor_data) omp_unset_lock(&sensor_locks[sensor_data.sensor_id]); } } } } 

When I try this - this leads to a deadlock.

Broadly, I am trying to parallize the computation of analytics as long as they are not being computed for the same sensor.

Can someone help with the idiomatic way of doing it ?

16
  • Can't you set some prints here and there to see at what point the program hangs? Commented May 31, 2023 at 11:44
  • sensor_data being a structure, beware how firstprivate makes a copy if it has pointer components. Commented May 31, 2023 at 11:52
  • Tried that. Couldnt figure it out. Will wait for someone with openMP experience to share perspective. Commented May 31, 2023 at 11:52
  • sensor_data does not have pointers. Commented May 31, 2023 at 11:53
  • 4
    How is sensor_data declared? I think we need to see more code, and ideally a minimal reproducible example Commented May 31, 2023 at 12:27

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.