Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28543 Discussions

Automatic OpenMP offload to GPU with ifx compiler and Microsoft Visual Studio

FortranUser22
New Contributor I
1,147 Views

Hello,

 

My code works fine without offloading to GPU.  When I select the option "Enable OpenMP offloading" in "Code Generation" in "Fortran" of project properties I get two errors:

 

1. Error Device name missing

2. Error#10401 error running 'offline compiler'

 

I m attaching screenshots of the errors and the options I selected in code generation.

 

I installed the latest version available on intel website of ifx (one api toolkit and HPC).

 

This is my processor: Intel® Core™ i9-11950H Processor

 

Thank you for your help.

 

 

 

 

0 Kudos
1 Solution
Ron_Green
Moderator
438 Views

You do need special drivers to allows offload to the GPU.  The factory drivers are for graphics only, not compute. 

I will say that Intel does not document the prerequisites well.

First, there is the oneAPI Installation Guide

 

On the Installation Guide page, there is a link to Prerequisites

This page is not so good, but near the bottom is a key link

 

Set Up Your System for Intel GPU

If you are using Intel GPU, you need to install the GPU drivers separately.

 

And on this page is FINALLY a link to your GPU 

 

That driver is necessary for offload to Intel GPUs from our ifx openmp implementation.

View solution in original post

11 Replies
Barbara_P_Intel
Employee
1,109 Views

Can you please post a reproducer?

Specific OpenMP TARGET directives are required to offload to Intel GPUs.

 

0 Kudos
Barbara_P_Intel
Employee
1,077 Views

One more thing... If you use DO CONCURRENT, that compute can be offloaded to an Intel GPU without changing your code. Compile with the option -fopenmp-target-do-concurrent (Linux) or /Qopenmp-target-do-concurrent (Windows).

See the Intel Fortran Developer Guide and Reference for more info.

0 Kudos
FortranUser22
New Contributor I
595 Views

Thank you for your reply. 

 

Does intel provide specialized courses where I can register to learn how to offload to GPU using intel fortran?

 

Thank you. 

0 Kudos
Ron_Green
Moderator
559 Views

There is this page with some helpful examples.  That might be a starting point.  There are references on the bottom of this page to books and tutorials in OpenMP.  

 

 But looking at your output, I have questions:

1) did you install the correct Device Driver for you GPU?  What GPU are you targeting, that is, what CPU and GPU do you have?

2) Intel Fortran installation: 

  1. What version of Intel Fortran are you using?
  2. Did you install the Intel oneAPI Base Toolkit or HPC Toolkit, or simply the Fortran compiler by itself from the Component Downloads page?
0 Kudos
FortranUser22
New Contributor I
505 Views

Thank you for your reply and for the link with the valuable resources.

I bought my computer with the CPU Intel® Core™ i9-11950H Processor (Intel® Core™ i9-11950H Processor). It should have integrated GPU (Intel® UHD Graphics for 11th Gen Intel® Processors).  I m assuming the intel offload to this GPU should work because it is made by intel.

 

My computer also has NVIDIA RTX A5500 GPU but from what I read, it would not work with intel GPU offload.

 

I m using the computer as bought so I m assuming all the drivers are installed properly.

 

I believe that I installed the Intel oneAPI Base Toolkit with intel ifx fortran compiler. The version is:  Intel(R) 64, Version 2024.0.2 Build 20231213.

 

So far I was not able to run any simple example of offload to GPU.

 

 

 

 

0 Kudos
Ron_Green
Moderator
439 Views

You do need special drivers to allows offload to the GPU.  The factory drivers are for graphics only, not compute. 

I will say that Intel does not document the prerequisites well.

First, there is the oneAPI Installation Guide

 

On the Installation Guide page, there is a link to Prerequisites

This page is not so good, but near the bottom is a key link

 

Set Up Your System for Intel GPU

If you are using Intel GPU, you need to install the GPU drivers separately.

 

And on this page is FINALLY a link to your GPU 

 

That driver is necessary for offload to Intel GPUs from our ifx openmp implementation.

FortranUser22
New Contributor I
322 Views

Thank you for your reply. I installed the GPU driver. How do I know for sure that it is offloading to GPU? 

0 Kudos
Ron_Green
Moderator
316 Views

If you set environment variable LIBOMPTARGET_PLUGIN_PROFILE=T

That can be done in Visual Studio or from the command line. 

 

This will print out each offload kernel that executed and how much time was taken, along with the amount of data transferred.  If you get that report it did indeed offload.  If not, it did not.

 

FortranUser22
New Contributor I
301 Views

FortranUser22_0-1716914941659.png

Thank you. I got the report above for the matrix multiplication example. It says thread 0, omp device (0). This is offload and run in parallel threads the code below?

 


!$omp target map(to: a, b ) map(tofrom: c )
!$omp parallel do private(j,i,k)
do j=1,n
do i=1,n
do k=1,n
c(i,j) = c(i,j) + a(i,k) * b(k,j)
enddo
enddo
enddo
!$omp end parallel do
!$omp end target

 

0 Kudos
FortranUser22
New Contributor I
300 Views

Sorry, I meant to ask the question: Did the code offload to GPU and the threads run in parallel? It says kernel 0 in the report table.

0 Kudos
FortranUser22
New Contributor I
296 Views

I set the environment variable in the command line as follows: " set LIBOMPTARGET_PLUGIN_PROFILE=T " and it worked.

I tried to set it with visual studio but it did not work:

FortranUser22_1-1716918380482.png

 

I also tried the following and it still did not work:

FortranUser22_2-1716918428716.png

 

0 Kudos
Reply