- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
Hello everybody,
I am using FORTRAN language in Visual Studio 2008, running in the following machine: 32 GB of RAM, Intel Core i7-3770 CPU @ 3.4GHz, 64 bit OS.
I have already finished my code (serial-type code), however I would like to parallelize it. I have already identified that the code takes most of the time solving the system of equations using CALL GBSV from the MKL library. This subroutine is called many times as it is a time-discrete problem. I read in one of the web forums that MKL is already "adjusted" to automatically support parallelism, is that right? If so, how can I do it in order to see the improvement in the CPU time. If I have to do it manually, can somebody please let me know how can I assign the 8 processors (threads of the shared memory PC I am working on) to work in the sole purpose of the subroutine GBSV? Please find the source code snippet.
Thank you very much in advance.
Regards,
JD.
dtn = dt ct = 1 sumdt = 0.0_dp do while (sumdt < tp) ct = ct + 1 call GBSV(BTMnni, RHSnn, Nz*Nth, IPIV, INFO) deallocate(Psfr, STAT = DeAllocateStatus) allocate(Psfr((Nz*Nr*Nth),ct), STAT = AllocateStatus) if (AllocateStatus /= 0) STOP "*** Not enough memory ***" Psfr(:,ct) = RHSnn(:,1) do i = 1,(ct-1) Psfr(:,i) = Psfrtemp(:,i) end do deallocate(Psfrtemp, STAT = DeAllocateStatus) allocate(Psfrtemp((Nz*Nr*Nth),ct), STAT = AllocateStatus) if (AllocateStatus /= 0) STOP "*** Not enough memory ***" Psfrtemp = Psfr do i = 1,(Nz*Nth*Nr) DeltaP(i) = abs(Psfr(i,ct) - Psfr(i,(ct-1))) end do DPMAX = maxval(DeltaP) if (DPMAX <= MULT*DPLIM) then sumdt = sumdt + dtn dtn = dtn*(DPLIM/DPMAX) if ((sumdt+dtn > tp) .AND. (sumdt /= tp)) then dtn = tp - sumdt end if BMnn = 0.0_dp do i = 1,(Nz*Nth*Nr) BMnn(i,i) = ((1.0_dp)/(dtn))*B(i) end do do i = 1,(Nz*Nth) if ((bcinboncongp(i) > 0.5_dp) .AND. (bcinboncongp(i) < 2.0_dp)) then WSv(i) = (C*Vijk(i))/(Vpws) else WSv(i) = 0.0_dp end if BMnn(i,i) = ((B(i)) + (WSv(i)))/(dtn) end do do i = 1,(Nz*Nth*Nr) BTMnn((1+(Nz*Nth)+(Nz*Nth)),i) = MDnn(i) + BMnn(i,i) end do BTMnni = BTMnn RHSnn(:,1) = matmul(BMnn,Psfr(:,ct)) - NNSSV else do while (DPMAX > MULT*DPLIM) dtn = dtn*(DPLIM/DPMAX) BMnn = 0.0_dp do i = 1,(Nz*Nth*Nr) BMnn(i,i) = ((1.0_dp)/(dtn))*B(i) end do do i = 1,(Nz*Nth) if ((bcinboncongp(i) > 0.5_dp) .AND. (bcinboncongp(i) < 2.0_dp)) then WSv(i) = (C*Vijk(i))/(Vpws) else WSv(i) = 0.0_dp end if BMnn(i,i) = ((B(i)) + (WSv(i)))/(dtn) end do do i = 1,(Nz*Nth*Nr) BTMnn((1+(Nz*Nth)+(Nz*Nth)),i) = MDnn(i) + BMnn(i,i) end do BTMnni = BTMnn RHSnn(:,1) = matmul(BMnn,Psfr(:,ct-1)) - NNSSV call GBSV(BTMnni, RHSnn, Nz*Nth, IPIV, INFO) deallocate(Psfr, STAT = DeAllocateStatus) allocate(Psfr((Nz*Nr*Nth),ct), STAT = AllocateStatus) if (AllocateStatus /= 0) STOP "*** Not enough memory ***" Psfr(:,ct) = RHSnn(:,1) do i = 1,(ct-1) Psfr(:,i) = Psfrtemp(:,i) end do deallocate(Psfrtemp, STAT = DeAllocateStatus) allocate(Psfrtemp((Nz*Nr*Nth),ct), STAT = AllocateStatus) if (AllocateStatus /= 0) STOP "*** Not enough memory ***" Psfrtemp = Psfr do i = 1,(Nz*Nth*Nr) DeltaP(i) = abs(Psfr(i,ct) - Psfr(i,(ct-1))) end do DPMAX = maxval(DeltaP) end do sumdt = sumdt + dtn dtn = dtn*(DPLIM/DPMAX) if ((sumdt+dtn > tp) .AND. (sumdt /= tp)) then dtn = tp - sumdt end if BMnn = 0.0_dp do i = 1,(Nz*Nth*Nr) BMnn(i,i) = ((1.0_dp)/(dtn))*B(i) end do do i = 1,(Nz*Nth) if ((bcinboncongp(i) > 0.5_dp) .AND. (bcinboncongp(i) < 2.0_dp)) then WSv(i) = (C*Vijk(i))/(Vpws) else WSv(i) = 0.0_dp end if BMnn(i,i) = ((B(i)) + (WSv(i)))/(dtn) end do do i = 1,(Nz*Nth*Nr) BTMnn((1+(Nz*Nth)+(Nz*Nth)),i) = MDnn(i) + BMnn(i,i) end do BTMnni = BTMnn RHSnn(:,1) = matmul(BMnn,Psfr(:,ct)) - NNSSV end if deallocate(tv, STAT = DeAllocateStatus) allocate(tv(ct), STAT = AllocateStatus) if (AllocateStatus /=0 ) STOP "*** Not enough memory ***" tv(ct) = sumdt do i = 1,(ct-1) tv(i) = tvtemp(i) end do deallocate(tvtemp, STAT = DeAllocateStatus) allocate(tvtemp(ct), STAT = AllocateStatus) if (AllocateStatus /= 0) STOP "*** Not enough memory ***" tvtemp = tv end do
Link copiado
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
Hello,
"I read in one of the web forums that MKL is already "adjusted" to automatically support parallelism, is that right? " Yes, that's right. MKL is automatically supports parallelism in the case if you link your application with threaded version of MKL instead of sequential. The most part of MKL's routines are threaded including gbsv.
From this snippet not clear what is the problem size and #of right hands in your case?
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
You can set mkl_set_num_threads(8) just before the MKL function call and this will specify the number of threads to be used for that function.
Please refer https://software.intel.com/en-us/node/471134
You may also try to set mkl_set_dynamic(0) for disabling MKL deciding the number of threads dynamically.
--Vipin
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
Good morning,
Thank you very much for the answers!
@Gennady Fedorov (Intel): The number of RHS is only 1. However, when I set up the following in the Project properties, the code actually spent 5 more minutes: Properties>Fortran>Optimization.Parallelization: Yes: (/Qparallel); Properties>Fortran>Language>Process OpenMP Directives: Generate Parallel Code (/Qopenmp).
@Vipin Kumar E K (Intel): I am trying to implement this commands, but I get an error #7002: Error in opening the compiled module file. Check INCLUDE paths.
This is what I included in the code, at the very beginning:
module mboundaries1 use minput use mgridding use mvectors use mwbgridmapping USE MKL95_PRECISION, ONLY: WP => DP USE MKL95_LAPACK, ONLY: GBSV use omp_lib use mkl_service implicit none save
And this is what I specified before using the GBSV MKL function call
call mkl_set_num_threads(8) call GBSV(BTMnni, RHSnn, Nz*Nth, IPIV, INFO)
However I got the error mentioned above. Can you lease let me know what exactly do I have to do to properly link the libraries? Where do I have to include the paths, if I have to do it between " " or ' ', do I have to add the source exiting file into my source files folder in visual studio?
Thank you very much.
JD.

- Subscrever fonte RSS
- Marcar tópico como novo
- Marcar tópico como lido
- Flutuar este Tópico para o utilizador atual
- Marcador
- Subscrever
- Página amigável para impressora