Software Archive
Read-only legacy content
17060 Discusiones

problem in setting threads at MIC

aketh_t_
Principiante
1.941 Vistas

hi all,

This a program, I had written in fortran.

!dir$ offload begin target(mic)
call omp_set_num_threads(240)
!dir$ end offload

!dir$ offload begin target(mic)
!$omp parallel
print *,The number of threads are',omp_get_num_threads()
!$omp end parallel
!dir$ end offload

However in the final output I still get 

The number of threads are 1

why? How do I set more threads?

 

0 kudos
4 Respuestas
aketh_t_
Principiante
1.941 Vistas

I did not compile with -openmp option as well

Sunny_G_Intel
Empleados
1.941 Vistas

Hello aketh,

Can you please clarify what are you trying to achieve. You mentioned you want to setup the openmp number of threads to 240 but you are not compiling with -openmp flag.  Can you please try the following:

program testset
 
include 'omp_lib.h'
!dir$ offload begin target(mic)
        call omp_set_num_threads(240)
!dir$ end offload
 
!dir$ offload begin target(mic)
!$omp parallel
        print *,'The number of threads are',omp_get_num_threads()
!$omp end parallel
!dir$ end offload
 
end program testset

 

Compile with

ifort -openmp -o testSet testSet.f90

and execute

./testSet

Let me know if you still do not see number of threads set to 240. 

Thanks

aketh_t_
Principiante
1.941 Vistas

Hi,

It worked. thank you. what I meant was I forgot to use -openmp option.

James_C_Intel2
Empleados
1.941 Vistas

A slight side issue, but... explicitly forcing 240 threads is a bad idea on multiple grounds.

  1. In offload one core is heavily loaded by the system transferring data, and your code would be better not using it
  2. Forcing the number of threads makes your code non-portable (what if you try to run it on a card with fewer cores?)

The system uses sensible defaults, so until you really understand what you're doing, don't change them! (And, when you do, use the envirables (KMP_PLACE_THREADS, KMP_AFFINITY), don't hard-wire these things into your code).

Responder