openmp

Is there an easy way to prepare Fortran code for parallel invocation

旧街凉风 提交于 2020-01-05 19:14:18
问题 I want to solve multiple large ODE systems in a C++ program in parallel using OpenMP. For certain reasons I need to use an ODE solver for which I could only find a Fortran 90 subroutine, and the code is too large to simply translate it to C. I know that Fortran uses static memory extensively and that I therefore have to prime the code for parallel invocations; but I am not really familiar with the language so: Is there a standard (automated) solution for my problem? Which parts of the code do

Is there an easy way to prepare Fortran code for parallel invocation

冷暖自知 提交于 2020-01-05 19:13:40
问题 I want to solve multiple large ODE systems in a C++ program in parallel using OpenMP. For certain reasons I need to use an ODE solver for which I could only find a Fortran 90 subroutine, and the code is too large to simply translate it to C. I know that Fortran uses static memory extensively and that I therefore have to prime the code for parallel invocations; but I am not really familiar with the language so: Is there a standard (automated) solution for my problem? Which parts of the code do

Parallelizing with OpenMP

岁酱吖の 提交于 2020-01-05 13:11:42
问题 I have problems parallelizing this code, I think I have to use the critical clause but I don't know how... #include <stdio.h> #include <sys/time.h> #define N4 5000 #define N5 5000 #define PIXMAX 10 #define NUM_THREADS 4 int i, j, k; int histo[PIXMAX], image[N4][N5]; void calculate_histo(int *array, int matrix[N4][N5]) { for(i=0; i<PIXMAX; i++) array[i] = 0; #pragma omp parallel { int array_private[PIXMAX]; for(i=0; i<PIXMAX; i++) array_private[i] = 0; #pragma omp for for(i=0; i<N4; i++) for(j

Parallelizing with OpenMP

我怕爱的太早我们不能终老 提交于 2020-01-05 13:11:27
问题 I have problems parallelizing this code, I think I have to use the critical clause but I don't know how... #include <stdio.h> #include <sys/time.h> #define N4 5000 #define N5 5000 #define PIXMAX 10 #define NUM_THREADS 4 int i, j, k; int histo[PIXMAX], image[N4][N5]; void calculate_histo(int *array, int matrix[N4][N5]) { for(i=0; i<PIXMAX; i++) array[i] = 0; #pragma omp parallel { int array_private[PIXMAX]; for(i=0; i<PIXMAX; i++) array_private[i] = 0; #pragma omp for for(i=0; i<N4; i++) for(j

Using unique_ptr<CCfits::FITS> in omp parallel for loop results in SEG.FAULT

≡放荡痞女 提交于 2020-01-05 09:33:44
问题 Take the following code: #include <omp.h> #include <CCfits/CCfits> #include <sys/stat.h> int main () { std::string file ( "somefits.fits" ); std::cout << file << std::endl; // check if file exists struct stat bf; if ( stat(file.c_str(),&bf ) ) { std::cerr << "Error: the file: " << file << " does not exist " << std::endl; exit(-1); } #pragma omp parallel for schedule (dynamic) for ( uint i = 0; i<4; ++i ) { std::unique_ptr<CCfits::FITS> fp (new CCfits::FITS (file, CCfits::Read)); // do

Using unique_ptr<CCfits::FITS> in omp parallel for loop results in SEG.FAULT

无人久伴 提交于 2020-01-05 09:31:55
问题 Take the following code: #include <omp.h> #include <CCfits/CCfits> #include <sys/stat.h> int main () { std::string file ( "somefits.fits" ); std::cout << file << std::endl; // check if file exists struct stat bf; if ( stat(file.c_str(),&bf ) ) { std::cerr << "Error: the file: " << file << " does not exist " << std::endl; exit(-1); } #pragma omp parallel for schedule (dynamic) for ( uint i = 0; i<4; ++i ) { std::unique_ptr<CCfits::FITS> fp (new CCfits::FITS (file, CCfits::Read)); // do

Passing too many arguments by reference could be inefficient?

荒凉一梦 提交于 2020-01-05 08:45:13
问题 Disclamer: I'm using Intel Compiler 2017 and if you want to know why I'm doing this, go at the end of the question. I have this code: class A{ vector<float> v; ... void foo(); void bar(); } void A::foo(){ for(int i=0; i<bigNumber;i++){ //something very expensive //call bar() many times per cycle; } } void A::bar(){ //... v.push_back(/*something*/); } Now, let's suppose I want to parallelize foo() since it's very expensive. However, I can't simply use #pragma omp parallel for because of v.push

“critical” an entire function

假如想象 提交于 2020-01-05 07:24:08
问题 I am trying to use openMP, and I have this one function that can never be run two times at the same time. In another world, this would not be a problem: int foo(void){ mutex->lock(); .... mutex->release(); } How can I achieve the same thing in OpenMP? 回答1: Use: #pragma omp critical (CriticalSection1) { // your stuff here } EDIT I hope this is clearer: int foo(void){ //mutex->lock(); #pragma omp critical (CriticalSection_foo) { .... } //mutex->release(); } EDIT 2 I extended the example to

“critical” an entire function

白昼怎懂夜的黑 提交于 2020-01-05 07:24:04
问题 I am trying to use openMP, and I have this one function that can never be run two times at the same time. In another world, this would not be a problem: int foo(void){ mutex->lock(); .... mutex->release(); } How can I achieve the same thing in OpenMP? 回答1: Use: #pragma omp critical (CriticalSection1) { // your stuff here } EDIT I hope this is clearer: int foo(void){ //mutex->lock(); #pragma omp critical (CriticalSection_foo) { .... } //mutex->release(); } EDIT 2 I extended the example to

Canon SDK: Download latest picture taken by two devices to host

混江龙づ霸主 提交于 2020-01-05 05:35:10
问题 I'm writing an windows based application in Visual Studio 2010. My host PC is connected to two Canon EOS 600D. So far I managed two take a picture, download it directly (without a SD card) to the host PC and store the pictures under a specific name on the host. If I execute my code in a loop, it also works fine (the index of the loop specifies the camera and the destination file). In a next step I used OpenMP2.0 to speed up the loop (this is my first project with OpenMP). Now the pictures are