Software Archive
Read-only legacy content
17060 Diskussionen

unable to compile program

aketh_t_
Einsteiger
1.658Aufrufe
use omp_lib
program openmp_mic
integer::threadcount
 !dir$ offload begin target (mic)  
     !$omp parallel 
      threadcount=omp_get_thread_num()
      print *,'The number of threads is ',threadcount
      print *,'hello from thread no ',omp_get_num_thread(),'of',threadcount
     !$omp end parallel
 !dir$ end offload
end program openmp_mic

Here is my sample program

i got the following error on compilation.

icc openmp_mic.f90

error #6785: This name does not match the unit name.   [OPENMP_MIC]

end program openmp_mic

------------^

 

any help?

0 Kudos
2 Antworten
pbkenned1
Mitarbeiter
1.658Aufrufe

You've got a few coding errors to correct:

The 'use omp_lib' has to appear after 'program openmp_mic'

Replace 'omp_get_num_thread()' with 'omp_get_thread_num()

I'd also suggest using 'omp master' when calling omp_get_num_threads(), otherwise every active thread on the device will be updating 'threadcount'.

Limit the number of threads in the parallel region, otherwise ~ 200 plus threads will make the output hard to read.

Suggested modifications attached.

[U543387]$ ifort -V
Intel(R) Fortran Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 15.0.2.164 Build 20150121
Copyright (C) 1985-2015 Intel Corporation.  All rights reserved.

[U543387]$ ifort -qopenmp U543387-wa.f90 -o U543387-wa.f90.x
[U543387]$ ./U543387-wa.f90.x
 The number of threads is            8
 hello from thread no            0 of           8
 hello from thread no            1 of           8
 hello from thread no            7 of           8
 hello from thread no            2 of           8
 hello from thread no            6 of           8
 hello from thread no            5 of           8
 hello from thread no            3 of           8
 hello from thread no            4 of           8
[U543387]$

 

Patrick

pbkenned1
Mitarbeiter
1.658Aufrufe

Attachments don't seem to be working, so here's the modified example:

program openmp_mic
use omp_lib
implicit none

integer :: threadcount

!dir$ offload begin target (mic)
     !$omp parallel num_threads(8)
        !$omp master
           threadcount=omp_get_num_threads()
           print *,'The number of threads is ',threadcount
        !$omp end master
        print *,'hello from thread no ',omp_get_thread_num(),'of',threadcount
     !$omp end parallel
!dir$ end offload

end program openmp_mic

Patrick

Antworten