- #1
- 5
- 0
Hello,
I need to call a Fortran DLL from C++. My program simulates difussion of some substances, I won't go into details.
I generate my data in C++ and I pass it to the Fortran code which does all the computation part. I repeat this a number of times and try to implement parallel execution using OpenMP.
Everything runs well, I actually try to test the execution speed for the fortran subroutine.
My code is run on an Intel P4. 1 physical core, 2 virtual cores available for multithreading.
Here is some c++ code:
I would like to get an answer for the following questions:
1. The execution without openMP takes ~15s and with openMP enabled ~12s. Why is the speedup so low (20% improvement in execution speed)? I mean, I know it shouldn't it be around twice, but still... I don't have I/O operations inside the Fortran subroutine.
2. To pass an array by reference from c++->fortran you do the following:
The array will be modified inside fortran, then passed to c++.
Now my question is: How do you do the same thing with a matrix ?(i.e. declaration, passing it by reference to fortran)
I need to call a Fortran DLL from C++. My program simulates difussion of some substances, I won't go into details.
I generate my data in C++ and I pass it to the Fortran code which does all the computation part. I repeat this a number of times and try to implement parallel execution using OpenMP.
Everything runs well, I actually try to test the execution speed for the fortran subroutine.
My code is run on an Intel P4. 1 physical core, 2 virtual cores available for multithreading.
Here is some c++ code:
Code:
#pragma omp parallel
{
#pragma omp for
for (i=1;i<=1000;i++)
{
///here i generate some random data : x,y,z...
///here i call fortran with that data: fortran_subroutine(x,y,z...)
}
}
I would like to get an answer for the following questions:
1. The execution without openMP takes ~15s and with openMP enabled ~12s. Why is the speedup so low (20% improvement in execution speed)? I mean, I know it shouldn't it be around twice, but still... I don't have I/O operations inside the Fortran subroutine.
2. To pass an array by reference from c++->fortran you do the following:
Code:
int *array;
array=new double[some_size];
//initialize array;
//write array[i] before
call_fortran(array);
//write array[i] after
Now my question is: How do you do the same thing with a matrix ?(i.e. declaration, passing it by reference to fortran)