I would like to use OpenMP to parallelize some of my functions in a c++ program.
I am using ubuntu 12.04, on intel i5 with 4 cores. But after following certain step
As mentioned by @Mikael Persson , I removed -fopenmp from the target link libraries and added
find_package(OpenMP)
if (OPENMP_FOUND)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
This is working.
The error r *** double free or corruption (!prev): 0x00007ff424006b20 ***
was arising because in the for loop, i was trying to use push_back()
function to load a stack and the index was dependant on the for loop index. I think that was the cause of the problem.
I learnt one more thing that one can have nested for loops and OMP can work without errors if their variables are independent and produce valid results