openmp

OpenMP in Fortran

痴心易碎 提交于 2019-12-22 07:57:31
问题 I very rarely use fortran, however I have been tasked with taking legacy code rewriting it to run in parallel. I'm using gfortran for my compiler choice. I found some excellent resources at https://computing.llnl.gov/tutorials/openMP/ as well as a few others. My problem is this, before I add any OpenMP directives, if I simply compile the legacy program: gfortran Example1.F90 -o Example1 everything works, but turning on the openmp compiler option even without adding directives: gfortran

data members in an OpenMP loop

独自空忆成欢 提交于 2019-12-22 06:41:03
问题 I have the following class: Class L{ public: bool foo(vector<bool> & data); private: C** cArray; } and would like to parallelize the for loop in the function foo which is called somtime after an object of L is created and all the elements in cArray are initialized. bool L::foo(vector<int> & data){ int row, col; #pragma omp parallel shared(SIZE, cArray, data) private(row, col) for (row=0, row<SIZE; ++row) { for (col=0; col<SIZE; ++col) { cArray[row][col].computeScore(data); } } } But this

How do I use the GPU available with OpenMP?

自古美人都是妖i 提交于 2019-12-22 05:57:11
问题 I am trying to get some code to run on the GPU using OpenMP, but I am not succeeding. In my code, I am performing a matrix multiplication using for loops: once using OpenMP pragma tags and once without. (This is so that I can compare the execution time.) After the first loop I call omp_get_num_devices() (this is my main test to see if I'm actually connecting to a GPU.) No matter what I try, omp_get_num_devices() always returns 0. The computer I am using has two NVIDIA Tesla K40M GPUs . CUDA 7

Xcode 4.5 and OpenMP with Clang (Apple LLVM) uses only one core

风流意气都作罢 提交于 2019-12-22 05:48:13
问题 We are using Xcode 4.5 on a C++11 project where we use OpenMP to speed up our computation: #pragma omp parallel for for (uint x=1; x<grid.width()-1; ++x) { for (uint y=1; y<grid.height()-1; ++y) { // code } } Although the Activity Monitor shows multiple threads being used by the program we observed that only one core is used: We also run the same code on Ubuntu using GCC 4.7 and we observed contention on all cores. Could it be that the OpenMP support has been removed in the Apple LLVM? Is

OpenMP on iOS/Android

本秂侑毒 提交于 2019-12-22 05:33:28
问题 OpenMP is supported in GCC which is cross-platform... but does that mean OpenMP is supported on all target platforms? Specifically, iOS and Android**... as phones/tablets move to quad-core, not using all the cores in games will be a huge disadvantage. ** As a non mobile-developer I don't know if you can write C++ apps for Android in the first place? 回答1: This is not necessarily the case. Example: http://groups.google.com/group/android-ndk/browse_thread/thread/a547eac5446035b4?pli=1 OMP is not

FFTW plan creation using OpenMP

五迷三道 提交于 2019-12-22 05:25:20
问题 I am trying to perform several FFT's in parallel. I am using FFTW and OpenMP. Each FFT is different, so I'm not relying on FFTW's build-in multithreading (which I know uses OpenMP). int m; // assume: // int numberOfColumns = 100; // int numberOfRows = 100; #pragma omp parallel for default(none) private(m) shared(numberOfColumns, numberOfRows)// num_threads(4) for(m = 0; m < 36; m++){ // create pointers double *inputTest; fftw_complex *outputTest; fftw_plan testPlan; // preallocate vectors for

Can std::atomic be safely used with OpenMP

◇◆丶佛笑我妖孽 提交于 2019-12-22 04:01:21
问题 I'm currently trying to learn ow to use OpenMP and I have a question. Is it safe to do something like that : std::atomic<double> result; #pragma omp parallel for for(...) { result+= //some stuff; } Or shall I use : double result; #pragma omp parallel for for(...) { double tmp=0; //some stuff; #pragma omp atomic result+=tmp; } Thanks ! Edit : I know the most simple way to handle that is using an array, but Im asking because I'm curious 回答1: Officially, no. In practice, probably. Page Section 1

OpenMP: Get total number of running threads

岁酱吖の 提交于 2019-12-22 03:48:11
问题 I need to know the total number of threads that my application has spawned via OpenMP. Unfortunately, the omp_get_num_threads() function does not work here since it only yields the number of threads in the current team. However, my code runs recursively (divide and conquer, basically) and I want to spawn new threads as long as there are still idle processors, but no more. Is there a way to get around the limitations of omp_get_num_threads and get the total number of running threads? If more

How can I best “parallelise” a set of four nested for()-loops in a Brute-Force attack?

柔情痞子 提交于 2019-12-21 17:52:05
问题 I have the following homework task: I need to brute force 4-char passphrase with the following mask % % @ @ ( where @ - is a numeric character, % - is an alpha character ) in several threads using OpenMP. Here is a piece of code, but I'm not sure if it is doing the right thing: int i, j, m, n; const char alph[26] = "abcdefghijklmnopqrstuvwxyz"; const char num[10] = "0123456789"; #pragma omp parallel for private(pass) schedule(dynamic) collapse(4) for (i = 0; i < 26; i++) for (j = 0; j < 26; j

What is easier to learn and debug OpenMP or MPI?

流过昼夜 提交于 2019-12-21 16:18:23
问题 I have a number crunching C/C++ application. It is basically a main loop for different data sets. We got access to a 100 node cluster with openmp and mpi available. I would like to speedup the application but I am an absolut newbie for both mpi and openmp. I just wonder what is the easiest one to learn and to debug even if the performance is not the best. I also wonder what is the most adequate for my main loop application. Thanks 回答1: If your program is just one big loop using OpenMP can be