Questions tagged [openmp]
OpenMP is a cross-platform multi-threading API which allows fine-grained task parallelization and synchronization using special compiler directives.
6,053
questions
1
vote
0
answers
36
views
How can I sum sub-matrices in Eigen
I have some matrix defined as:
Eigen::MatrixXd DPCint = Eigen::MatrixXd::Zero(p.szZ*(p.na-1),p.szX);
\\ perform some computations and fill every sub-matrix of size [p.szZ,p.szX] with some values
#...
0
votes
0
answers
37
views
OMP : How to avoid clause : Reduction?
In a loop, a subroutine mySub that calculates a matrix myThreadMatrix is called. The result is summed in mySumMatrix that has a clause REDUCTION
program main
use omp_lib
implicit none
...
1
vote
1
answer
77
views
Fortran OMP : how to do a parallel and a single task?
I am a newbie in parallel programming. This is my serial code that I would like do parallelize
program main
implicit none
integer :: pr_number, i, pr_sum
real :: pr_av
pr_sum = 0
do i=1,...
0
votes
2
answers
33
views
OpenMP. Parallelization of two consecutive cycles
I am studying OpenMP and have written an implementation of shaker sorting. There are 2 consecutive cycles here, and in order for them to be called sequentially, I added blockers in the form of ...
0
votes
2
answers
41
views
How is OpenMP communicating between threads with what should be a private variable?
I'm writing some code in C++ using OpenMP to parallelize some chunks. I run into some strange behavior that I can't quite explain. I've rewritten my code such that it replicates the issue minimally.
...
1
vote
0
answers
47
views
omp parallel for with race condition from -fsanitize=thread
I am using OpenMP for some basic multiprocessing computations and a very simple code is producing data races when compiled with sanitizers but seems to work correctly with any number of threads once ...
0
votes
2
answers
67
views
Parallelize for-loop in c++ - memory error
I am trying to parallelize a for-loop in C++, but every time I try to use this loop for a larger data set, I get this error:
Process returned -1073741819 (0xC0000005)
For small data sets the loop ...
0
votes
0
answers
53
views
Openmp do I have false sharing or Race condition?
I'm learning Openmp, and I'm working on compressed sparse row multiplication (datatype std::complex<int>). And I'm getting different execution time each time I run the following function:
...
0
votes
1
answer
42
views
Why does the speedup I get by parallelizing with OpenMP decrease after a certain workload size?
I'm trying to get into OpenMP and wrote up a small piece of code to get a feel for what to expect in terms of speedup:
#include <algorithm>
#include <chrono>
#include <functional>
#...
-2
votes
0
answers
24
views
OpenMp parallel solution [duplicate]
I am a beginner at parallelization, can somebody help me with how to make this program parallel with OpenMP? I'm trying but won't work. The running time is always almost the same.
{
double start =...
1
vote
2
answers
96
views
Array Padding does not mitigate false sharing? C, OpenMP
#include <stdio.h>
#include <omp.h>
static long num_steps = 100000000; double step;
#define PAD 8
#define NUM_THREADS 6
void main(){
int i, nthreads; double pi=0, sum[NUM_THREADS][PAD]={0};...
-1
votes
1
answer
42
views
How to rewrite and optimize an array in a for loop with OpenMP?
Now I hope to optimize the assignment of the inliers vector in parallel. There is no requirement for the assignment order of the inliers vector. Just put the value in C that meets the if requirements ...
0
votes
1
answer
52
views
Parallel for nested loops in openmp
I have problem to parallel for-loop code in OpenMP, result of parallel for-loop is different with a sequential for-loop. How to make this code parallel with same result as sequential code.
const long ...
-1
votes
2
answers
42
views
OpenMP not spawning additional threads
I'm new to OpenMP and cannot for the life of me utilise multiple threads. I have my environment variable set. Here is a snippet of code which simply should just iterate through the mandelbrot set:
#...
0
votes
0
answers
29
views
Why OpenMP gives different result every time even though I'm using Critical? [duplicate]
The following C program calculate the value of PI using multiple threads.
#include <stdio.h>
#define N 10000000
int main(int argc, char **argv)
{
long int i, n = N;
double x, dx, f, sum,...
1
vote
1
answer
161
views
Why I am getting different output in every run in openmp
I have N number of text files. I am trying to read from those files parallelly, so I have forked N threads and each thread gets one text file from those N files(Thread 0 gets file0.txt, thread 1 gets ...
0
votes
2
answers
71
views
Need Help Understanding OpenMP Matrix Multiplication C++ code
Here is my Matrix Multiplication C++ OpenMP code that I have written. I am trying to use OpenMP to optimize the program. The sequential code speed was 7 seconds but when I added openMP statements but ...
1
vote
2
answers
66
views
OpenMP. Parallelization of the loop in N threads
I am trying to parallelize a cycle of 50 million iterations with several threads - first by 1, then by 4, 8 and 16. Below is the code for implementing this functionality.
#include <iostream>
#...
1
vote
1
answer
71
views
Measuring bandwidth on a ccNUMA system
I'm attempting to benchmark the memory bandwidth on a ccNUMA system with 2x Intel(R) Xeon(R) Platinum 8168:
24 cores @ 2.70 GHz,
L1 cache 32 kB, L2 cache 1 MB and L3 cache 33 MB.
As a reference, I'm ...
0
votes
0
answers
89
views
Explanation for strange peak in weak scaling plot
I'm running a simple kernel which adds two 3rd order tensors of double-precision complex-values. I've parallelized it using OpenMP with custom scheduling: the slice_indices container contains ...
0
votes
1
answer
17
views
How can I make the out_dotp.err stop causing errors
I need help, I have been messing with this code for hours , it is supposed to perform the dot product operation in a paralel manner yet I cannot get it to output any result and all I get is ...
0
votes
1
answer
48
views
openmp increasing number of threads increases the execution time
I'm implementing sparse matrices multiplication(type of elements std::complex) after converting them to CSR(compressed sparse row) format and I'm using openmp for this, but what I noticed that ...
-1
votes
2
answers
18
views
warning: ‘dot_prod’ may be used uninitialized in this function [-Wmaybe-uninitialized]
I have been tinkering with this code and I cannot seem to make it work. when I run the error file it generates I get the warning
dotp.c:39:11: warning: ‘dot_prod’ may be used uninitialized in this ...
0
votes
1
answer
38
views
OpenMP parallel reduction (min) incorrect result
i am using OpenMP reduction(min) to get the minimum number of lock acquisitions in a parallel section over all participating threads.
When printing each threads counter inside the parallel section, I ...
1
vote
1
answer
57
views
OpenMP task firstprivate
I have a question regarding the OpenMP task pragma, if we suppose the following code:
#pragma omp parallel
{
x = omp_get_thread_num();
#pragma omp task firstprivate(x)
//do something with x
}
as ...
1
vote
0
answers
41
views
Can auto-vectorization be automatically done by #pragma omp simd? [duplicate]
In order to use auto-vectorization for a c++ code which will be running on x86-64 and aarch64 processors, is just adding #pragma omp simd in the code is sufficient? I plan to compile in windows using ...
0
votes
0
answers
34
views
no speedup using openmp simd and different result between icc and gcc [duplicate]
I am new to Openmp and now trying to use Openmp + SIMD intrinsics to speedup my program, but the result is far from expectation.
/* program:simd.c */
#include<stdio.h>
#include<stdlib.h>
...
1
vote
2
answers
46
views
How does OpenMP actually reduce clock cycles?
It might be a silly question but, with OpenMP you can achieve to distribute the number of operations between all the cores your CPU has. Of course, it is going to be faster in 99% times because you ...
-2
votes
2
answers
72
views
Why is my matrix multiplication code not working?
I am new to C++ and I have written a C++ OpenMp Matrix Multiplication code that multiplies two 1000x1000 matrices. So far its not running and I am having a hard time finding out where the bugs are. I ...
0
votes
1
answer
54
views
How to test the problem size scaling performance of code
I'm running a simple kernel which adds two streams of double-precision complex-values. I've parallelized it using OpenMP with custom scheduling: the slice_indices container contains different indices ...
5
votes
2
answers
167
views
Thread safety of a static random number generator
I have a bunch of threads, each one needs a thread safe random number. Since in my real program threads are spawned and joined repeatedly, I wouldn't like to create random_device and mt19937 each time ...
1
vote
0
answers
38
views
Definition of a static variable inside a parallel region [duplicate]
I have a parallel region, I have a static variable defined inside this region, like this
#pragma omp parallel
{
static int var;
// some stuff
}
Without threadprivate, static variables are ...
1
vote
2
answers
139
views
How to optimize my C++ OpenMp Matrix Multiplication code
I have written a C++ OpenMp Matrix Multiplication code that multiplies two 1000x1000 matrices.
So far I have gotten a 0.700 sec execution time using OpenMp but I want to see if there is other ways I ...
0
votes
1
answer
41
views
use of undeclared identifier 'omp_get_thread_num()'
I was trying to train an SVM 1 vs all classifier with OpenCV(c++) in parallel manner since each class can be trained without waiting training of the other classes. While using #pragma omp parallel for ...
0
votes
1
answer
53
views
Reduce omp critical section to compare_exchange_weak in BFS
I have this working implementation of BFS.
std::unordered_map<decltype(root->id()), std::atomic<bool>> visited;
#pragma omp parallel
{
#pragma omp for
for ...
#pragma ...
1
vote
2
answers
66
views
OpenMP array initialization impact
I am working in parallel with OpenMP on an array (working part). If I initialize the array in parallel before, then my working part takes 18 ms. If I initialize the array serially without OpenMP, then ...
5
votes
1
answer
42
views
why does omp_get_schedule() return a monotonic schedule when OMP_SCHEDULE=static?
I am compiling my code with g++8.5 on redhat8 and I notice that when I set OMP_SCHEDULE=static, then inside my application omp_get_schedule() returns a "monotonic" schedule instead of a &...
0
votes
1
answer
37
views
How to ensure data synchronization with OpenMP?
When I try to do the math expression from the following code the matrix values are not consistent, how can I fix that?
#pragma omp parallel num_threads (NUM_THREADS)
{
#pragma omp for
...
0
votes
2
answers
104
views
OpenMP has low CPU usage
My OpenMP Implementation shows a really bad performance. When I profile it with vtune, I have a super low CPU usage and I don't know why. Does anyone have an idea?
Hardware:
NUMA architecture with 28 ...
1
vote
1
answer
40
views
Wrong result with OpenMP to parallelize GEMM
I know OpenMP shares all variables declared in an outer scope between all workers. And that my be the answer of my question. But I really confused why function omp3 delivers right result while ...
1
vote
1
answer
29
views
Serializing err.h calls in a mulit-threaded program
My program uses the <err.h> functions (like warnx(3)) to emit diagnostics. Sometimes multiple threads do the reporting at the same time, resulting in the output lines overlapping.
It is not a ...
0
votes
2
answers
58
views
How can I make a binary that uses openmp and compiled with intel's C compiler portable?
Normally I compile code (all in a single file main.c) with the intel oneapi command prompt like so
icl.exe main.c -o binary_name
I can then run binary_name.exe without issue from a regular command ...
-2
votes
0
answers
24
views
How do I statically link an openmp library using intel's icl.exe compiler on windows
Take the toy code
#include <stdlib.h>
#include "omp.h"
int main()
{
#pragma omp parallel
{}
return EXIT_SUCCESS;
}
I would like to do something like:
icl.exe main.c /...
0
votes
2
answers
71
views
Using OpenMP and MPI in the same program
I am currently working on an assignment for my parallel programming class in which I need to write the same program sequentially, then parallelized using OpenMP then parallelized using MPI.
For ...
1
vote
2
answers
65
views
OMP parallel for is not dividing iterations
I am trying to do distributed search using omp.h. I am creating 4 threads. Thread with id 0 does not perform the search instead it overseas which thread has found the number in array. Below is my code:...
-1
votes
0
answers
52
views
How to know where to place OpenMp directives to achieve optimal parallelism
I am taking a intro parallel class, and we are tasked with parallelizing this code below with the help of OpenMP directives, the code is a stencil algorithm that performs sweeps through multi-...
3
votes
1
answer
62
views
Can I conditionally define an openMP parallel region?
I can write some code that looks like this:
if (make_parallel)
{
#pragma omp parallel for
for (int i=0; i<n; i++)
{
//For loop stuff
}
}
else
{
//Identical for loop, ...
2
votes
0
answers
19
views
Incorrect claim about (in)correct use of OMP DO-construct in "official" Fortran OMP tutorial?
This tutorial about parallel programming using OpenMP in Fortran, found on
the OpenMP website, contains the following example (see pages 11-12):
real(8) :: A(1000), B(1000)
do i = 1, 1000
B(i) = ...
0
votes
1
answer
66
views
Using omp parallel for in multiplication algorithm (BigInt multiplication)
For educational purpose I'm developing c++ library for operating with large numbers represented as vectors of chars (vector<char>).
Here is algorithm that I am using for multiplication:
string ...
0
votes
1
answer
47
views
C++ omp for loop with conditional counter (not loop index, not a reduction)
I am parallelizing a code where elements of an array B are a function of elements of an array A. B is smaller than A (i know both sizes in advance) and B[n] is written only if A[n] satisfy a certain ...