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

Are loop variables in Fortran SAVEd?

I have SAVE statement in subroutine or function. Also I haven't IMPLICIT NONE. In that case are loop variables in Fortran SAVEd? Example: FUNCTION GLOB7S(P) REAL LONG LOGICAL mess COMMON/iounit/konsol,mess …
2
votes
1 answer

How to statically link OpenMP library via `clang` and `gcc` for python module?

I'm developing a python module that is written in C++ but callable from python via bindings written via pybind11. I'm trying to cross-compile for M1 Macs from an Intel Mac using Apple's XCode Toolchain. Interestingly, for some users the package…
2
votes
0 answers

Where exactly should I write the OpenMP "THREADPRIVATE" directive for common blocks and SAVE variables in FORTRAN?

Can you please tell me exactly where to place the OpenMp THREADPRIVATE directive for the common block? Immediately after the description of this block, immediately after the description of this block and all other variables of any kind, or only…
2
votes
2 answers

sparse matrix multiplication program openmp

I'm looking for any standard C program that uses OpenMP APIs for a sparse matrix-vector or matrix-matrix multiplications. Can anyone let me know if there are any such programs.
krs
  • 21
  • 2
2
votes
1 answer

How to properly use #pragma omp simd?

I'm trying to understand whether the code below is OpenMP standard compliant. The main concern here is the args object that contains an offset field that is modified inside a loop to which #pragma omp simd is applied. Is this a legit use…
Nobody
  • 53
  • 1
  • 6
2
votes
2 answers

Can OpenMP's SIMD directive vectorize indexing operations?

Say I have an MxN matrix (SIG) and a list of Nx1 fractional indices (idxt). Each fractional index in idxt uniquely corresponds to the same position column in SIG. I would like to index to the appropriate value in SIG using the indices stored in…
drakon101
  • 524
  • 1
  • 8
2
votes
1 answer

CPU/Threads usage on M1 Pro (Apple Silicon) using openMP

hope someone knows the answer to this... I have a code that compiles perfectly well with openMP (it uses libsharp). However, I am finding it impossible to make the M1 Pro chip use all the 8 or 10 cores I have. I am setting the threads variable…
2
votes
1 answer

Is it ok for CMake to use c++, rather than mpicxx, to compile my code?

I'm trying to build an executable from C++ source code which uses MPI, on a GNU/Linux Devuan Chimaera system. Now, I'm an MPI/OpenMP newbie, I'm just trying to adapt this code, which isn't mine, to be built with CMake - when before it had a…
einpoklum
  • 118,144
  • 57
  • 340
  • 684
2
votes
2 answers

Default Variable Scope in OpenMP

I am learning OpenMP in C programming and trying to understand the default scope of variables in different cases. Given this code, I am a bit confused about the scope of pointers and their respective variable values. For example *x and x, and *y and…
Draconian
  • 33
  • 3
2
votes
1 answer

Freeze/Fail when using functional with OpenMP [Pybind11/OpenMP]

I have a problem with the functional feature of Pybind11 when I use it with a for-loop with OpenMP. I've done some research and my problem sounds pretty similar to the one in this Pull Request from 2 years ago, but although this PR is closed and the…
chicom
  • 35
  • 4
2
votes
1 answer

Is that possible to let Fortran source code detect compiler flags?

The question is inspired by OpenMP with BLAS The motivation is, I want the Fortran source code to be flexible to the complier options related to serial/parallel BLAS. I may specify -mkl=parallel for mkl or USE_OPENMP=1 for lopenblas in the…
AlphaF20
  • 583
  • 6
  • 14
2
votes
0 answers

Python C extension compiled with nvc++ OpenMP offloading cannot run on GPU

I have a Python extension in C/C++ that I want to use OpenMP offloading with. Using NVIDIA's nvc++, compiling works out as well as using/running the extension in python. The problem ist that it's not using the GPU by default. Setting…
ThiloOS
  • 92
  • 7
2
votes
3 answers

Sparse matrix parallel creation with openmp in fortran

I am relatively new to fortran, and totally new to openmp, I have the following problem : I want to construct a (big : ~1% non zero elements over ~1 million to 1 billion elements in total) sparse matrix (value,row,column) in parallel, my code…
bslhrzg
  • 23
  • 2
2
votes
1 answer

C ++ using multiple cores breakes output , code for a math problem

So, for start im just starting to learn c++, and i had to resolve this problem: Find the numbers with the propriety : 5 * 5 = 25 , 25 * 25 =625(25squared), 6*6 =36(6squared) ( 25 is the ending of 625, 5 is the the ending of 25 ). So i've got my code…
2
votes
1 answer

OpenMP incredibly slow when another process is running

When trying to use OpenMP in a C++ application I ran into severe performance issues where the multi-threaded performance could be up to 1000x worse compared to single threaded. This only happens if at least one core is maxed out by another…