Software Archive
Read-only legacy content
17060 Discussions

problem in setting threads at MIC

aketh_t_
Beginner
1,939 Views

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 Replies
aketh_t_
Beginner
1,939 Views

I did not compile with -openmp option as well

0 Kudos
Sunny_G_Intel
Employee
1,939 Views

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

0 Kudos
aketh_t_
Beginner
1,939 Views

Hi,

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

0 Kudos
James_C_Intel2
Employee
1,939 Views

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).

0 Kudos
Reply