openmp

How do we enable OpenMP to use multiple cores — glintenet

萝らか妹 提交于 2019-12-08 11:00:08
问题 I want to use glinternet a R function that implements a feature extraction methodology developed by the Stanford professor Trevor Hastie and a PhD student. The function has an argument numCores. According to the user manual: numCores Number of threads to run. For this to work, the package must be installed with OpenMP enabled. Default is 1 thread. I don't know though how to enable OpenMP. I have Windows 8. Your advice will be appreciated. 回答1: Here is the answer of the glinternet package

OpenMP Pi example outcome always changes rather than 3.1415

只谈情不闲聊 提交于 2019-12-08 10:17:18
问题 I'm new to openMP and C, I tried the "Introduction to OpenMP - Tim Mattson (Intel)" Pi example but the outcome is not 3.14. I compare the code with teacher. They are same. But the result is different #include <omp.h> #include <stdio.h> #include <stdlib.h> //OpenMP example program: hello; static long num_steps = 100000; #define NUM_THREADS 2 double step; int main() { int nnum,i,j=0; step= 1.0/(double)num_steps; double sum[NUM_THREADS]; double x,pi,result=0.0; omp_set_num_threads(NUM_THREADS);

Using continue inside the paralleld for loop

情到浓时终转凉″ 提交于 2019-12-08 10:06:43
问题 My code looks-like as below: #pragma omp parallel for num_threads(5) for(int i = 0; i < N; i++) { //some code //#pragma omp parallel for reduction(+ : S_x,S_y,S_theta) for(int j = 0; j < N; j++) { if (j==i) continue; // some code for(int ky = -1; ky<= 1; ky++) { for(int kx = -1; kx<= 1; kx++) { //some code if (r_ij_square > l0_two) { //some code } } } } //some code } I'm not sure if continue in above code could cause any prblem or not. To avoid any problem, I have ignored second #pragma in

OpenMP - for loop thread assignment

半世苍凉 提交于 2019-12-08 09:23:55
问题 Suppose I have an array with indices 0..n-1. Is there a way to choose which cells each thread would handle? e.g. thread 0 would handle cells 0 and 5 , thread 1 would handle cells 1 and 6 and so on.. 回答1: You can even be more explicit: #pragma omp parallel { int nth = omp_get_num_threads(); int ith = omp_get_thread_num(); for (int i=ith; i<n; i+=nth) { // handle cell i. } } this should do exactly what you want: thread ith handles cell ith, ith+nth, ith+2*nth, ith+3*nth and so on. 回答2: Have you

OpenMP False Sharing

只愿长相守 提交于 2019-12-08 08:14:59
问题 I believe I am experiencing false sharing using OpenMP. Is there any way to identify it and fix it? My code is: https://github.com/wchan/libNN/blob/master/ResilientBackpropagation.hpp line 36. Using a 4 core CPU compared to the single threaded 1 core version yielded only 10% in additional performance. When using a NUMA 32 physical (64 virtual) CPU system, the CPU utilization is stuck at around 1.5 cores, I think this is a direct symptom of false sharing and unable to scale. I also tried

How to make OpenMP thread or task run on a certain core

女生的网名这么多〃 提交于 2019-12-08 07:54:50
问题 Is there a way to make an OMP thread or task run on a certain core? I found this, followed the link, but I couldn't find the source code to test it. Also this is an Intel solution to it (I think). Does OMP support this itself? 回答1: As far as I know as of OpemMP 3.0 they're all vendor specific extensions. For example GOMP (GCC's implementation) honours the environment variable GOMP_CPU_AFFINITY for setting thread affinity. In their documentation they give the example: GOMP_CPU_AFFINITY="0 3 1

OpenMP False Sharing

≡放荡痞女 提交于 2019-12-08 07:53:28
I believe I am experiencing false sharing using OpenMP. Is there any way to identify it and fix it? My code is: https://github.com/wchan/libNN/blob/master/ResilientBackpropagation.hpp line 36. Using a 4 core CPU compared to the single threaded 1 core version yielded only 10% in additional performance. When using a NUMA 32 physical (64 virtual) CPU system, the CPU utilization is stuck at around 1.5 cores, I think this is a direct symptom of false sharing and unable to scale. I also tried running it with Intel VTune profiler, it stated most of the time is spent on the "f()" and "+=" functions. I

binding threads to certain MPI processes

徘徊边缘 提交于 2019-12-08 07:29:18
问题 I have the following setup, a hybrid MPI/OpenMP code which runs M MPI processes with N threads each. In total there are MxN threads available. What I would like to do, if possible, is to assign threads only to some MPI processes not to all of them, my code would be more efficient since some of the threads are just doing repetitive work. Thanks. 回答1: Your question is a generalised version of this one. There are at least three possible solutions. With most MPI implementations it is possible to

f2py: using openMP parallel in fortran fails

血红的双手。 提交于 2019-12-08 06:52:51
问题 I am trying to compile a fortran routine that uses openMP for python using f2py . This is the file bsp.f90 : module OTmod !$ use omp_lib implicit none public :: get_threads contains function get_threads() result(nt) integer :: nt nt = 0 !$ nt = omp_get_max_threads() !$omp parallel num_threads(nt) write( *, * ) 'hello world!' !$omp end parallel end function get_threads end module OTmod If I compile it with f2py -m testmod --fcompiler=gfortran --f90flags='-fopenmp' -lgomp -c bsp.f90 compilation

Bind threads to specific CPU cores using OpenMP

隐身守侯 提交于 2019-12-08 06:06:59
问题 I know that GOMP_CPU_AFFINITY binds threads to specific cores. But in example what they have given here, it gives: GOMP_CPU_AFFINITY="0 3 2 1" Here, thread0 gets attached to---> cpu0 thread1 gets attached to---> cpu3 thread2 gets attached to---> cpu2 thread3 gets attached to---> cpu1 This is clear. But How can I set thread0 to core0 and core2 at same time ? What will be the value of Environment variable "GOMP_CPU_AFFINITY" for it ? 回答1: This GOMP reference may help you. To answer your