Questions tagged [openmp]
OpenMP is a cross-platform multi-threading API which allows fine-grained task parallelization and synchronization using special compiler directives.
6,539
questions
0
votes
0
answers
49
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
94
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
171
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
132
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 ...
-1
votes
4
answers
170
views
Looking for a good way to use openMP with recursive code?
I wanted to optimize recursion with openMP. So, I started from this question:
best-way-to-parallelize-this-recursion-using-openmp
While looking to optimize recursive functions I was first interested ...
0
votes
1
answer
84
views
DFS and BFS traversal using OpenMP
This words fine. Or seems to. It runs and gives the right output.
#include <conio.h>
#include <stdlib.h>
//#include "omp.h"
#include "iostream"
#define infinity 9999
#...
4
votes
0
answers
178
views
Performance of Memory Allocation, Multiple Threads and Various Allocation Size
I write an application which needs to create up to millions of objects per second. I found that memory allocation has a large impact on performance. Therefore I think about writing my own memory ...
0
votes
0
answers
67
views
why does openmp causes huge increase in memory?
I am trying to perform a parallel graph traversal. The entire code has only one shared variable (writable) - i would like to know why the memory consumption is too much for this. As per my ...
-2
votes
2
answers
70
views
OpenMP: parallel op and errno at once?
While omp_thread_num is maintained for a full iteration, the same underlying thread won't necessarily perform the execution.
This made me wonder how omp deals non omp thread locals, i.e. __thread int; ...
0
votes
3
answers
61
views
does OpenMP prohibit a throw inside a parallel region even when not running multithreaded?
First of all, yes, I am aware of answers such as this on SO:
Throwing a C++ exception inside an omp critical section
But I don't think it answers my specific question. Here's my situation. I have a ...
1
vote
1
answer
64
views
Parallel threads doing the same until a barrier, after barrier the result is not always the same
Several threads increment a value in an array in parallel. Every thread increments its own value, not changing the one of the others. After each incrementation we have a barrier so that threads wait ...
1
vote
1
answer
96
views
How to properly choose which variables should be private/shared/reduced in nested do-loops in Fortran with openmp?
I have the following subroutine, which is my stepper function in a bigger DEM program. It computes every interaction between particles i and j, then updates the forces. I am now trying, as a first ...
0
votes
1
answer
28
views
Is there false-sharing when writing to unique elements of an output array?
Is there false-sharing with sum[] in the following snippet of code that computes the row-wise sums of a sparse CSR matrix since independent threads update distinct locations of the array which could ...
1
vote
0
answers
76
views
OpenMP exclusive scan reduction segfaults as N increases
I have the following code where I am performing an exclusive scan. This code works up until N gets large enough. On my machine it started to segfault when N=10000000. What exactly is the issue here?
#...
0
votes
0
answers
44
views
Paralellizing Recursive Functions
i have the following recursive function:
void find_words(char grid[ROWS][COLS], int row, int col, char prefix[MAX_WORD_LENGTH], int visited[ROWS][COLS], node_t** table) {
// Mark current ...
1
vote
1
answer
119
views
Why is it slow when OpenMP runs in parallel independent instances of shortest path algorithm that uses BFS (BFS in itself is not parallelized)?
I am trying to run multiple instances of a shortest path algorithm, for independent pairs of nodes in a graph.
The algorithm internally uses the bfs method, which is "sandboxed" (self-...
0
votes
0
answers
38
views
race condition of OpenMP in nested loop
I am new to multithreading, I tried a few solutions, but I couldnt get it to work.
I am using nanoflann to do a knn search, and loop through the neighbours.
In order to remove repeated pairs, I had a ...
0
votes
0
answers
332
views
address not mapped to object at address (nil)
I can compile my FORTRAN code successfully but receive the following error message when I try to run it.
Loading compiler version 2022.0.2
Loading tbb version 2021.5.1
Loading compiler-rt version 2022....
0
votes
0
answers
110
views
Can I use SIMD (C++) when I am accessing the same memory location with different indexes?
I am currently trying to parallelize with OMP SIMD a for loop which has multiple indirections, i.e., gather and scatter operations.
I initialize parallelized with
#pragma omp for
and i verified the ...
1
vote
0
answers
94
views
OpenMP pragma parallel for only using a single thread
I am refactoring some old code which uses OpenMP to parallelise some heavy calculations. The program is written in C.
System specs:
2x 48-Core Xeons
750GB RAM
Ubuntu 20
It is worth noting the the ...
0
votes
0
answers
39
views
How to configure OpenMP when using VS2019 with Qt VS Tools as the compiler?
When i use VS2019 with Qt VS Tools,i want to use OpenMP to accelerate my calculation,but it doesn't work,i wonder how to configure it to make it work.(i choose to enable openmp in VS2019),here is my ...
0
votes
0
answers
40
views
OpenMP parallel for inside while inside for (or even inside while)
I have an algorithm that is cost expensive. I want to parallelise it by the use of OpenMP.
I have the following algorithm in fortran 95
!For a number of iterations
DO iter=1,itermax
t=tinter
!We ...
0
votes
1
answer
86
views
potential gfortran or openMP bug when using "omp if" and "reduction"
I have a MWE where an omp reduction breaks if I add the option for GPU offloading (even if it isn't used).
I know I can do a work-around using preprocessor directives but I would really prefer to ...
0
votes
0
answers
19
views
EXC_BAD_ACCESS when accessing private variables in OpenMP? [duplicate]
When I was parallelising for-loops using OpenMP in Xcode, there seemed to be a memory access error for private variables (large 2D number arrays, around 2000*2000) that were originally declared as ...
0
votes
0
answers
85
views
OpenMP wrong results when more than 1 thread used
Preface
I know there are many similar titled questions. I read quite all of them, but I post this one since the causes might different from all those cases. And I would appreciate your judgement and ...
2
votes
1
answer
106
views
Parallelizing for the Fortran Nested loop
I used OpenMP with COLLAPSE clause to parallelise the nested the Fortran loop. The code can be compiled successfully but it gives me the following error message when I run it.
Loading compiler-rt ...
0
votes
0
answers
40
views
openmp for LZW data compression using c++
Am trying to parallelize the compression process using OpenMP. Currently trying to parallelize it while all threads uses the same dictionary. But error seems to occur when trying to add new contents ...
0
votes
0
answers
83
views
Eigen matrix manipulation acceleration with OpenMP
I am new to OpenMP, trying to accelerate the following for loop, but I cannot get the parallel version faster than the sequential computation.
The code snippet is as below:
typedef Eigen::Matrix<...
0
votes
0
answers
77
views
Unable to compile with GNU C++ 12 and LLVM 16 headers and libraries @ Ubuntu Focal
I'm struggling to compile a custom OpenMP tool library on an Ubuntu system (Ubuntu 20.04.6 LTS, focal). To compile the code I use a GNU C++ compiler v12.2.1. GNU toolchain is built from source. My ...
0
votes
1
answer
119
views
Using Reduction in nested for loops with OpenMP and Eigen
I am trying to parallelize the following function (an iterative solver) that has a while loop and a nested for loop inside. The code looks like:
static const int nx = 128;
static const int ny = 128;
...
0
votes
1
answer
73
views
It is possible to use OpenMP on these fortran loops?
Here is my problem: I have a fortran code with a certain amount of nested loops and I would like to know if it's possible to use OpenMP to parallelize them?
Here is the fortran code:
ia = 0
do i=1,...
0
votes
0
answers
83
views
How to rewrite code with SAVE and ENTRY statements for OpenMP usage?
I am rewriting for OpenMP usage a large Fortran-77 program and one of the files contains a subroutine in which important variables marked as SAVE are initialized the first time the main program is ...
0
votes
0
answers
52
views
Using Parallelism in cython, but why no change in performance
I am learning cython by following the official cython tutorials.I had some problems when trying the section ‘Cython for NumPy users’ in Cython's Documentation.
The address is: https://cython....
0
votes
0
answers
100
views
LLVM TSan and OpenMP explicit Tasks
I'm getting warnings about data races from Thread Sanitizer in this toy example:
#include <vector>
#include <algorithm>
#include <iostream>
int main () {
std::vector<int> ...
0
votes
2
answers
94
views
need help parallelizing c++ program with OpenMP
I have this piece of code, that I'm trying to parallelize with OpenMP. It uses a vector of vectors loaded with points (X, Y and Z coordinates) and then it rotates and shift the points and finds the ...
-1
votes
1
answer
369
views
Why cmake on macOS M2 can't find OpenMP?
I have managed to compile OpenMP on my macbook but it does not run the application on multiple threads. I used the answer here.
Here is my CMakeList.txt:
cmake_minimum_required(VERSION 3.12)
project(...
1
vote
1
answer
81
views
OpenMP with C++: Internal Compiler Error with parallelized Lambda in Template Function
I have code that calls a template function which defines a lambda and then calls it. When trying to parallelize the lambda using a custom reduction in OpenMP, I get an internal compiler error. I'm ...
0
votes
0
answers
58
views
Efficiency comparison for omp Fortran loop with array operation
I am comparing the efficiency for openmp in Fortran with different organizations on loop indices and whether split indices
For the given code
Program test
Use, Intrinsic :: iso_fortran_env, Only : ...
1
vote
0
answers
106
views
OpenMP nested parallel regions way slower than expected
On a ccnuma system with 4 nodes and 128 cores, i am calculating a sparse matrix - vector product.
Below are two different omp setups, version 1 just creates 128 threads and spreads them among the ...
0
votes
0
answers
123
views
How to efficient parallel matrix multiplication for small external indices and large internal indices in Fortran
I have a matrix multiplication, A[na,nb]*B[nb,nc]=C[na,nc]. na and nc are small, nb is large. How to efficient parallel in this case? (if na and nc are large, that would be straightforward, to split ...
0
votes
0
answers
48
views
Understanding template compilation when providing template functions in a library
I'm working on a library that implements a template function which is parallelized using OpenMP.
I want to compile my library using the -fopenmp option so that anyone who links against my library gets ...
1
vote
0
answers
65
views
PETSc: OMP+MKL in MatShell
I am trying to use a custom matvec operator with PETSc MatShell in Fortran and inside of it, I want to use a mix of OpenMP and MKL multithreading (blas).
The OpenMP and MKL threads are indeed launched,...
1
vote
0
answers
27
views
Why reduction working in one case but not in another case?
Following are the two code snippets where I am working with OpenMP reduction, in the first case (reduction variable total_num_sp_edges) every time I get the correct result, but in the second case, ...
1
vote
1
answer
258
views
OpenMP Offload Error during linking with gcc with nvptx-none: unresolved symbol _fputwc_r
I am trying to compile a simple test problem using OpenMP offloading for an Nvidia GPU. I am using gcc with the nvptx-none target. I have installed the gcc+nvptx package with spack (or compiled gcc-13 ...
0
votes
0
answers
49
views
make call to external threaded library be single threaded inside omp parallel region
I am making a nested parallelism inside a C++ code.
I am parallelizing a for-loop with #omp parallel for, and inside the for-loop I have a call to an external library. That is, each iteration of the ...
0
votes
0
answers
47
views
Parallelising function on struct array in OpenMP
I'm currently writing an N-body gravitation and simulation code. After successfully implementing a few integrators and force codes for single core use, I decided to try my hand at multithreading with ...
1
vote
2
answers
554
views
Parallelize the "for loop" iterations in python using openmp
I want to parallelize the "for loop" iteration using OpenMP threads or similar techniques in python.
The code is shown below. "idexs" iterates for 1024 times and all it does is ...
0
votes
1
answer
40
views
MPI Win_post/start/complete/wait with OpenMP endless waiting
I am trying to combine MPI one sided communication with OpenMP tasks.
The program sets up a cartesian communication and communicates some data. Without the OpenMp parts everthing works fine. Here is ...