openmp

Set thread affinity on two cores using OpenMP

懵懂的女人 提交于 2020-01-16 08:12:46
问题 I am using a C program, compiled with gcc 4.9.2 on Windows7, using OpenMP 4.0. My computer is dual core, with four threads. I'd like to use thread affinity spread and use 2 threads put on different cores. So when I set the environment variables from DOS with: set OMP_NUM_THREADS=2 set OMP_PROC_BIND=spread set OMP_PLACES="cores" I get, with the variable OMP_DISPLAY_ENV=true, this: libgomp: Invalid value for environment variable OMP_PLACES OPENMP DISPLAY ENVIRONMENT BEGIN _OPENMP = '201307' OMP

Why does the compiler ignore OpenMP pragmas?

百般思念 提交于 2020-01-16 06:58:06
问题 In the following C code I am using OpenMP in a nested loop. Since race condition occurs, I want to perform atomic operations at the end: double mysumallatomic() { double S2 = 0.; #pragma omp parallel for shared(S2) for(int a=0; a<128; a++){ for(int b=0; b<128;b++){ double myterm = (double)a*b; #pragma omp atomic S2 += myterm; } } return S2; } The thing is that #pragma omp atomic has no effect on the program behaviour, even if I remove it, nothing happens. Even if I change it to #pragma oh_my

Why does the compiler ignore OpenMP pragmas?

落爺英雄遲暮 提交于 2020-01-16 06:57:13
问题 In the following C code I am using OpenMP in a nested loop. Since race condition occurs, I want to perform atomic operations at the end: double mysumallatomic() { double S2 = 0.; #pragma omp parallel for shared(S2) for(int a=0; a<128; a++){ for(int b=0; b<128;b++){ double myterm = (double)a*b; #pragma omp atomic S2 += myterm; } } return S2; } The thing is that #pragma omp atomic has no effect on the program behaviour, even if I remove it, nothing happens. Even if I change it to #pragma oh_my

OpenMP parallelization (Block Matrix Mult)

僤鯓⒐⒋嵵緔 提交于 2020-01-15 11:11:07
问题 I'm attempting to implement block matrix multiplication and making it more parallelized. This is my code : int i,j,jj,k,kk; float sum; int en = 4 * (2048/4); #pragma omp parallel for collapse(2) for(i=0;i<2048;i++) { for(j=0;j<2048;j++) { C[i][j]=0; } } for (kk=0;kk<en;kk+=4) { for(jj=0;jj<en;jj+=4) { for(i=0;i<2048;i++) { for(j=jj;j<jj+4;j++) { sum = C[i][j]; for(k=kk;k<kk+4;k++) { sum+=A[i][k]*B[k][j]; } C[i][j] = sum; } } } } I've been playing around with OpenMP but still have had no luck

C++ OpenMP slower than serial with default thread count

☆樱花仙子☆ 提交于 2020-01-15 09:13:32
问题 I try using OpenMP to parallel some for-loop of my program but failed to get significant speed improvement (actual degradation is observed). My target machine will have 4-6 cores and I currently rely on the OpenMP runtime to get the thread count for me, so I haven't tried any threadcount combination yet. Target/Development platform: Windows 64bits using MinGW64 4.7.2 (rubenvb build) Sample output with OpenMP Thread count: 4 Dynamic :0 OMP_GET_NUM_PROCS: 4 OMP_IN_PARALLEL: 1 5.612 // <-

Sequential and parallel versions give different results - Why?

情到浓时终转凉″ 提交于 2020-01-15 05:24:12
问题 I have a nested loop: (L and A are fully defined inputs) #pragma omp parallel for schedule(guided) shared(L,A) \ reduction(+:dummy) for (i=k+1;i<row;i++){ for (n=0;n<k;n++){ #pragma omp atomic dummy += L[i][n]*L[k][n]; L[i][k] = (A[i][k] - dummy)/L[k][k]; } dummy = 0; } And its sequential version: for (i=k+1;i<row;i++){ for (n=0;n<k;n++){ dummy += L[i][n]*L[k][n]; L[i][k] = (A[i][k] - dummy)/L[k][k]; } dummy = 0; } They both give different results. And parallel version is much slower than the

OpenMP flush vs flush(list)

允我心安 提交于 2020-01-15 05:00:05
问题 In OpenMP I can flush either a specified set of variables or the whole cache. Does anybody have an idea of the performance of this operation? Does it make sense to flush only the variables that really have changed or is the "flush all" so fast, that I should not worry? I have linked lists that I need to flush in my threads from time to time. Should I iterate through the list and flush each element individually, or simply flush everything ? 回答1: Given the advice in the OpenMP 3.1 standard: Use

Generating more tasks than there are threads

纵饮孤独 提交于 2020-01-15 04:59:33
问题 I read in several OpenMP tutorials that you should not generate more tasks than there are threads. For example: "Do not start more tasks than there are available threads, which means available in the enclosing parallel region." Assume that we want to traverse a binary tree, that the subtrees of a node can be traversed in parallel, and that our machine has four cores. Following the advice above, we generate two tasks at the root, one for the left and one for the right subtree. Within both

Using OpenMP with Clang and CMake in Visual Studio

假装没事ソ 提交于 2020-01-15 03:11:50
问题 I'm trying to compile a simple app to test a few libraries I might be using in the future. Because of some problems I had with msvc I tried Clang, which made a strange error I got disappear. The problem I have now is that the libraries I want to test use OpenMP. They import it using the FindOpenMP module CMake privides. However the module doesn't find it with Clang. cmake_minimum_required(VERSION 3.14.0) project(blaze-test VERSION 0.1.0) set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD

High performance implement of atomic minimal operation

泄露秘密 提交于 2020-01-14 06:01:30
问题 There is no atomic minimal operation in OpenMP, also no intrinsic in Intel MIC's instruction set. #pragmma omp critial is very insufficient in the performance. I want to know if there is a high performance implement of atomic minimal for Intel MIC. 回答1: According to the OpenMP 4.0 Specifications (Section 2.12.6), there is a lot of fast atomic minimal operations you can do by using the #pragma omp atomic construct in place of #pragma omp critical (and thereby avoid the huge overhead of its