Questions tagged [openmp]
OpenMP is a cross-platform multi-threading API which allows fine-grained task parallelization and synchronization using special compiler directives.
6,532
questions
0
votes
0
answers
31
views
BFS for islands in a graph returns empty vectors
I have the following function
vector<uint8_t> ConnectedComponents() {
vector<uint8_t> independent_nodes;
vector<bool> Visited(NumVertices, false);
for (uint8_t vertex = 0;...
0
votes
0
answers
88
views
'invalid option: --enable-cxx' after running 'brew install homebrew/science/hdf5 --enable-cxx'
I'm trying to run a cpp file using Rcpp. The error that keeps popping up is clang: error: unsupported option '-fopenmp'. After reading a bit, it seems to be the issue that I'm using Mac OS which does ...
0
votes
0
answers
71
views
How to compare time between sequential and parallel code using OpenMP?
I am trying to measure speedup for different number of threads of the parallel code, where speedup is the ratio of the compute time for the sequential algorithm to the time for the parallel algorithm. ...
0
votes
1
answer
30
views
Openmp parallelize vector of objects
I have a vector of objects, each an instance of a machine learning agent class. For the purposes of this task, it's only important that each instance of this class must run a complicated costly run() ...
0
votes
1
answer
68
views
OpenMP not found using MinGW / gfortran on Windows 10
I'm using GNU Fortran 9.2.0 with all latest updates and upgrades on Windows 10. I would like to compile a code that uses OpenMP.
Trying gcc -v, I see --enable-libgomp.
Trying to compile the code with ...
1
vote
1
answer
45
views
Android NDK app crashed when linking with OpenMp
In the Android NDK project, I linked with OpenMp in CMakeLists.txt by
find_package(OpenMP)
if (OPENMP_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(...
0
votes
1
answer
102
views
include_dirs for OpenMP in CMakeLists [duplicate]
I met a project which enable omp and has this line of code in CMakeLists.txt:
include_directories(${CMAKE_CUR_DIR} /usr/lib/llvm-11/include/openmp/)
and I tried to make it more general like:
...
0
votes
0
answers
57
views
Pytorch cpu-only build from source failing with caffe2 on
I was trying to build caffe2 within Pytorch directory but couldn't find a way to build it. The build seems to fail always. Can somebody tell what & how to do?
git clone --recursive https://github....
3
votes
1
answer
107
views
omp for loop for constexpr indexes
Suppose I have a function depending on a nontype template argument, an std::size_t, which can take value 0,...,N-1, with N known at compile time.
An iteration over all values can be done with a std::...
1
vote
1
answer
102
views
Can't reproduce normally distributed random numbers in parallel
I want to generate a reproducible sequence of random numbers in parallel with OpenMP. I wrote a small code that creates for each thread its own RNG with different seed. But when I start generating ...
0
votes
2
answers
75
views
Use of OpenMP in filling the array elements
Program test
!$ use omp_lib
implicit none
!$ call omp_set_num_threads(4)
integer :: i, j
integer, parameter :: dimen = 5
real (kind = 8), dimension(dimen, dimen) :: ...
0
votes
0
answers
28
views
hybrid MPI-OpenMP job directive with LSF
I am running the WRF-ARW code that seems to have the best performances when compiled and run in hybrid MPI-OpenMP execution.
I am working on a Lenovo cluster with 36 cores per node, managed by the LSF ...
0
votes
1
answer
109
views
OpenMP column-major access to a large memory-mapped array is (sometimes) slow
I've got a large binary file of doubles, representing an array with 650000 rows and 10210 columns -- it takes up about 53 GB. We are using C mmap (via <sys/mman.h>) to access it.
Unfortunately, ...
0
votes
0
answers
25
views
I am Unable to run the openMP program
#include "omp.h"
#include <iostream>
using namespace std;
int main()
{
omp_set_num_threads(4);
}
I am using this command to run the code g++ -fopenmp program.cpp -o program
The ...
0
votes
0
answers
113
views
when adding more threads to my parallel program (C++ OpenMp with Cplex library) it becomes slower
I have a program having a function that has a for loop, at each iteration the loop solves a Cplex problem. every problem has some similar constraints with the others, and has also its particular ...
1
vote
0
answers
25
views
GPU offloading of triangular loop
I have triangular loop to calculate forces, which I ported to GPU via OpenMP offloading:
!$omp target teams distribute parallel do simd &
!$omp private(i,j,ii,jj,rinvdenom,tp,index,fix0) &...
3
votes
0
answers
138
views
IntelOMP and LLVM OMP colliding
We have a conda environment that apparently causes issues when running:
/opt/miniconda/lib/python3.10/site-packages/threadpoolctl.py:546: RuntimeWarning:
Found Intel OpenMP ('libiomp') and LLVM ...
0
votes
0
answers
65
views
I want to run independant simulations with openmp where only one parameter change each time
I run simulations with allocated array, and I want to use open mp to run a simulation with each of my 4 threads. Every variables should be private since I there is only one parameter that change ...
1
vote
0
answers
69
views
ld: error: undefined symbol: omp_init_nest_lock when executing C code on Android Studio
I'm developing a mobile application on Android Studio based on a code generated by MATLAB Coder.
I've just added the .c files on CmakeFiles.txt to check if the gradle would compile. Instead, it is ...
1
vote
0
answers
42
views
User defined reduction when target cannot be used in intermediate steps of reduction
In the following code case, I am trying to add many std::array to an std::span with OpenMP.
The problem is that std::span cannot be used as an intermediate type in a tree reduction of addition ...
3
votes
0
answers
201
views
OpenMP - Weird Result in Combination of parallel and SIMD namespaces
I have a C++ project which uses OpenMP, and in some place in the code I have #pragma omp simd nested inside #pragma omp parallel. There was a consistent crash in the code which happened only in multi-...
0
votes
1
answer
89
views
OpenMP and OpenMPI using SLURM
I am trying to understand how to correctly write SLURM scripts to maximize parallelism.
For example, let's propose the following escenario: I have a program written in OpenMPI and OpenMP has the ...
0
votes
1
answer
89
views
Thread Sanitizer and Intel OpenMP
We are using GCC and Intel OpenMP.
I know that the combination of GCC and GCC OpenMP needs a special build of OpenMP (to use pthread interfaces rather than directly use the futex system call).
Is it ...
0
votes
1
answer
63
views
OpenMP parallelization of nested loops
I am practicing for an exam and I would like to know how to solve correctly the following C program using OpenMP.
The following program searches the biggest element in positions i..N-1 from vector
...
0
votes
0
answers
44
views
Why does OpenMP Nested SIMD Operation Crash in Debug Compilation
I'm working on an C++ project compiled with icpc which is parallelized using OpenMP5.
I had a bug causing my program to crash when compiling in debug mode, and run fine when compiling in release mode. ...
0
votes
0
answers
146
views
Eigen C++ crashes on matrix multiplication with openMP support enabled
I have the following C++ Eigen code that simply multiplies two matrices together in non-parallel and parallel processing fashion and compares the timing. I am using Visual Studio 2022 in Windows 10. I ...
0
votes
1
answer
67
views
N-body simulation using openMP in C
I have programmed a simulation for the n-body simulation using openMP, where each process represents a single mass Point.
The program compiles fine at the moment, but as you can see, I have several ...
2
votes
0
answers
104
views
Performance slowdown using a pointer to perform a reduction vs. using a normal variable
I need to perform an OpenMP reduction in C using a pointer variable (single element). As far as I know, the two alternatives to achieve this are:
double ptr* = ...
#pragma omp for reduction(max:ptr[0])...
1
vote
0
answers
82
views
A question about the efficiency of auto parallel openblas
I tried to use openblas to do a matrix multiplication and use its parallel version without writing DGEMM to different threads. The efficiency is not good when the common dimension is large. Is that a ...
-1
votes
3
answers
82
views
Why does "#pragma omp loop for" produce a compile error?
Why doesn't this compile? The following MRE is built from a number of examples trying to get OpenMP and OpenACC to work together. The compile command produces the following error:
$ mpic++ -mcmodel=...
0
votes
0
answers
48
views
Using OpenMP to optimize this code on multiple threads
I am having trouble optimizing this code. When attempting to put the for loops in parallel and use reductions and/or tiling and loop unrolling the code is having issues.
void parallel_to_grayscale(...
0
votes
1
answer
48
views
OpenMP task reduction with target offloading segfaults when running single threaded
I was using OpenMP with target offload and found that my application segfaults when limiting OpenMP to a single thread.
I could boil it down to the following snippet:
#include <omp.h>
int main()...
3
votes
2
answers
398
views
Why rxode2 cannot build model after I installed OpenMP
EDIT 4 (2023/06/22)
I'm trying to create a PK model using rxode2 package. Unfortunately, I got an error message stating error building model when using rxode({...}) function. Since I'm using a Mac (OS ...
1
vote
1
answer
75
views
Why is OpenMP reduction failing with error message 'user defined reduction not found for 'avgs'?'
Why is the reduction in this code throwing an error:
user defined reduction not found for 'avgs'
void parallel_avg_pixel(long img[DIM_ROW][DIM_COL][DIM_RGB], long *avgs) {
int row, col, pixel;
...
0
votes
0
answers
48
views
Inconsistent and incorrect results when running my code in parallel with different numbers of threads
I have a Fortran code that utilizes OpenMP. When I run the code without OpenMP or with OpenMP and with 9 threads, I obtain correct results. The code essentially consists of a single subroutine called ...
0
votes
1
answer
98
views
OpenMP multiple FIFO task queues
I am new to OpenMP so took some time to figure out the right way to ask the question so that its easier for experts to understand my queries.
I am been trying to formulate the best way to ask the ...
0
votes
2
answers
65
views
OpenMP enforce the order in which tasks are created
I am new to OpenMP and think my use case is not simple - hence looking for pointers on approach.
Is there a way to enforce execution of tasks in order they are spawned in OpenMP?
What I want to ...
0
votes
0
answers
50
views
OpenMP SIMD vectorization on multiple nested loops
I have loops doing products, and wanted to use vectorization on it with OpenMP SIMD instructions.
I tried something, with a temporary variable to apply the reduction, but didn't get any improvement (...
1
vote
1
answer
431
views
Use OpenMP on M2 Mac with R and data.table
I am struggling to use OpenMP with R and data.table on an M2 Mac Running macOS Ventura 13.3.1. I am following the instructions at https://mac.r-project.org/openmp/. Any help would be greatly ...
0
votes
0
answers
62
views
Spawning tasks for asynchronous work in OpenMP
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 ...
0
votes
0
answers
39
views
Why is my OpenMP code experiencing high latency in production despite performing well in development environment?
Below is a parallel task model using omp.
The proc1, ..., proc4 each costs below 1ms to finish. And in develop environment(2 physical CPU, 16 core in total) the job finishes perfectly.
But in ...
1
vote
1
answer
66
views
How remove data dependency in RK4 method Open MP C++
I'm trying to write parallel code for Runge-Kutta 4th order.
For this goal i use Open MP and try parallelize general loop. In first version i use summarize array in second version reduction sum. ...
0
votes
0
answers
76
views
OMP doesn't compile after enabling visual studio flag
My project is in c and visual studio 2022. This for loop compiles fine with "Open MP Support" set to "No" in the C/C++ language properties.
#pragma omp parallel for
for (int i=0; i ...
0
votes
1
answer
136
views
Do openMP calls pthreads? How threads are created in openMP?
I have the following doubts:
do openMP make pthread calls?
how threads are created in openMP?
is openMP a replacement to pthreads? or openMP and pthreads are entirely different?
if openMP and ...
0
votes
0
answers
48
views
How to parallelize a nested loop by OpenMP?
This code fragment solves a system of linear equations using the simple iteration method:
int n_iter;
double error = eps + 1;
double *x_new = (double *)malloc(N * sizeof(double));
...
1
vote
0
answers
18
views
Problem in writing openMp code, it doesn't work as expected
I was asked to i was asked to write an OpenMP programs that calculates the Euclidean distance between two vectors of equal length n. Each process/thread should generate a portion of each vector and ...
1
vote
1
answer
101
views
Problem in modifying shared armadillo matrix with OpenMP
I tried using omp in RcppArmadillo in the following toy example
#include <RcppArmadillo.h>
#include<omp.h>
// [[Rcpp::depends(RcppArmadillo)]]
// [[Rcpp::plugins(cpp11)]]
// [[Rcpp::...
2
votes
1
answer
93
views
Regarding OpenMP Parallel SIMD Reductions
I have a rather simple for loop summing a very large array of double values x (100 mio data points) in C. I want to do this in parallel with SIMD reductions, using a specified number of threads. The ...
2
votes
1
answer
167
views
malloc in openmp for parallel loop
I am bit confused what is a better way to use malloc()/free() in openmp parallel for loop. Here are two ways I thought of but I am not aware of which method is better. I learned from previous answers ...
0
votes
0
answers
127
views
Is clang's thread sanitizer reporting a false positive?
Consider the following, simple parallel computation of the /square/ of the elements of a vector using the OpenMP library. After the computation I print the vector element by element. However, I still ...