Questions tagged [openmp]

OpenMP is a cross-platform multi-threading API which allows fine-grained task parallelization and synchronization using special compiler directives.

OpenMP is a cross-platform multi-threading API which allows fine-grained task parallelization and synchronization using special compiler directives. OpenMP offers easy access to multi-threading without requiring knowledge of system-dependent details. At the same time, it is reasonably efficient compared to fine-tuned implementations with the bonus of being easiest to write multi-threads code. Forums and complete information on OpenMP is at https://openmp.org/.

OpenMP is based on multi-thread model, and offers Shared Memory parallelism and heterogeneous programming for coprocessors through compiler directives, library routines and environment variables. It is restricted to C/C++ and Fortran applications, however provides portability across different Shared Memory architectures.

It is through directives, added by the programmer to the code, that the compiler adds parallelism in the application. OpenMP can be used in single or multi-cores machines, in the first architecture the compiler directives are ignored, thus the application is executed in a sequential manner, promoting portability between the two architectures.

Latest version is 5.2 (November 2021): Official OpenMP specifications.

Definitive Book Guide

Helpful links

6462 questions
2
votes
1 answer

OpenMP offloading says 'fatal error: could not find accel/nvptx-none/mkoffload'

I'm trying to compile the following simple OpenMP GPU offloading program with G++ 9.3.0: #include int main(){ const int N=1000; int d[N]; for(auto i=0;i
Richard
  • 56,349
  • 34
  • 180
  • 251
2
votes
1 answer

Parallel simulation gives different results after some time steps when compared with serial and additional parallel runs

I am trying to run a code on vortex simulations in parallel using OpenMP. These are similar to particle simulations where at each time step, the position of a vortex at the next time step has to be computed from its velocity which is determined by…
2
votes
2 answers

Are the indices in an OpenMP loop processed in ascending order?

Consider the following OpenMP for loop: #pragma omp parallel for schedule(dynamic) for (int i = 0; i < n; ++i) { //do something with i } Is it guaranteed that each OpenMP thread sees its i values in ascending order?
AbuBakr
  • 968
  • 2
  • 11
  • 22
2
votes
1 answer

OpenMP - Iterator in the For-loop

#pragma omp parallel for reduction(+ : numOfVecs) for(itc=clus.begin() ; itc!=clus.end() ; itc++) { numOfVecs += (*itc)->getNumOfVecs(); } I have a couple of codes like the code above where I need iterators in the loop. But I get the error…
serkank
  • 79
  • 1
  • 7
2
votes
3 answers

dot product of complex vectors with openMP

I'm using a version of openMP which does not support reduce() for complex argument. I need a fast dot-product function like std::complex< double > dot_prod( std::complex< double > *v1,std::complex< double > *v2,int dim ) { std::complex< double…
pawel_winzig
  • 902
  • 9
  • 28
2
votes
1 answer

Is this explicit linking against OpenMP::OpenMP_CXX still necessary with this CMake linking command?

I am using CMake and GNU's parallel algorithms and the following code snippet in my CMakeLists.txt: if (OPENMP_FOUND) set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") …
Hirek
  • 435
  • 3
  • 12
2
votes
1 answer

OpenMP named critical section: if a program variable is used, is it evaluated or is it used as string without being evaluated?

I have the following piece of code which I want to add omp for to: for ( int i = 0 ; i < N ; i++ ) { double max2 = 0.; (calculate max2); for ( int j = 0 ; j < 3 ; j++) { int m = group[i].member[j]; if ( members[m].norm…
2
votes
1 answer

CMake Error: Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS) using clang on Mac OS

I'm trying to get triSYCL to work and for that I need OpenMP. I'm trying to build my project with this CMakeLists file: cmake_minimum_required(VERSION 3.16.2) project(acDataFlow) if (NOT DEFINED AC_DATA_FLOW_ROOT_DIR) message(WARNING…
Gian Laager
  • 474
  • 4
  • 14
2
votes
0 answers

Should I run a single parallelized C script from Python or a parallel set of serial C scripts?

Overview I am working on re-writing and optimizing a set of MATLAB scripts for a computationally intensive scientific computing application into a set of Python scripts with the kernels written in C (run using ctypes). The Python wrapping is…
2
votes
2 answers

No speedup with OpenMP when using Matlab MEX in Linux

I'm using OpenMP to speed up Fortran code in a Matlab MEX-file. However, I find that OpenMP seems not work on Linux, but actually works on Windows. I attach the code as follows: 1) Matlab Mex file: clc; clear all; close all; tic FLAG_SYS = 0; % 0…
kun zhao
  • 35
  • 5
2
votes
2 answers

OpenMP C++ parallel performance better dualcore laptop than eight cores cluster

First of all, OpenMP obviously only runs in one of the motherboards in the cluster, in this case each motherboard has two quad-core Xeons E5405 at 2GHz and its running Scientific Linux 5.3 (released in 2009, red hat based). My laptop on the other…
carlosperate
  • 594
  • 4
  • 11
2
votes
0 answers

Can an Rcpp::IntegerVector (ever) be used with OpenMP?

I am probably being greedy for performance, but I've observed significant performance gains when combining Rcpp and OpenMP in possibly illict ways. I understand that "Calling any of the R API from threaded code is ‘for experts only’ and strongly…
Hugh
  • 15,521
  • 12
  • 57
  • 100
2
votes
1 answer

OpenMP in MATLAB C Mex file is only producing 1 thread

I have the following simple C code which is compiled in MATLAB using mex -v COMPFLAGS="$COMPFLAGS -fopenmp" LDFLAGS="$LDFLAGS -fopenmp" MEXTESTER.c. I am using MATLAB R2019a, running on Windows 10 Home 64-bit with 6 cores available. Mex is…
Anders
  • 61
  • 4
2
votes
1 answer

How to insert inline PTX into OpenMP Code? Like we can do in CUDA code for Nvidia PTX Assembly?

I have an OpenMP code segment (parallel region). I want to add inline PTX assembly at the indicated line (shown below) I am using Nvidia gtx1070 gpu and ubuntu Linux and clang compiler. I tried asm volatile() method, but clang compiler throws…
2
votes
1 answer

MPI + Open MP Hybrid Initialization

I am using Mac OS with CLion IDE and my task is to use both parallel libraries (Open MP and MPI). The problem is Undefined symbols for architecture x86_64: "_MPI_Init", referenced from: _main in main.c.o ld: symbol(s) not found for…
siftoshka
  • 53
  • 1
  • 1
  • 9
1 2 3
99
100