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

Run a Fortran program on GPU

eliopoulos
초보자
5,504 조회수

eliopoulos_0-1755535963680.png

I have an Asrock intel arc a770 phantom gaming 16gb oc GPU and I try to run my Fortran program on it. When I build the solution, I get the above warnings and errors. Is there anything I can do to make it work?

0 포인트
14 응답
Ron_Green
중재자
5,474 조회수

Did you install the Arc GPU driver?  Our documentation on the prerequisite drivers is somewhat obscure, though necessary:
https://www.intel.com/content/www/us/en/docs/oneapi/installation-guide-windows/2025-2/install-intel-gpu-drivers.html

 

 

 

0 포인트
eliopoulos
초보자
5,461 조회수
0 포인트
Mark_Lewy
소중한 기여자 I
5,305 조회수

It appears to me that you don't have the Intel oneAPI DPC++/C++ Compiler installed.
I think you need it to generate code to offload to a GPU.

It is a available as an option in the HPC Toolkit installer.

0 포인트
eliopoulos
초보자
5,291 조회수
0 포인트
Mark_Lewy
소중한 기여자 I
5,270 조회수

I compiled this very simple program and it appears to be offloading, according to vtune:

program offload_test
    implicit none
    integer, parameter :: n = 1000000
    real, allocatable :: a(:), b(:), c(:)
    integer :: i

    allocate(a(n), b(n), c(n))

    ! Initialize arrays
    a = 1.0
    b = 2.0

    !$omp target teams distribute parallel do map(to: a, b) map(from: c)
    do i = 1, n
        c(i) = a(i) + b(i)
    end do

    print *, "First element of c: ", c(1)
    print *, "Last element of c: ", c(n)
end program offload_test

ifx 2025.2.0, VS 2022 LTSC 17.12.4

Options for a debug build:
/nologo /debug:full /Od /Qopenmp-targets:spir64 /Qopenmp /Qiopenmp /warn:interfaces /module:"x64\Debug\\" /object:"x64\Debug\\" /traceback /check:bounds /check:stack /libs:dll /threads /dbglibs /c

 

0 포인트
eliopoulos
초보자
5,224 조회수

Here is my program along with the input files (continued in the next post). To build the solution, you should set: /Qmkl, /integer-size:64 and /Qoverride-limits. Can you make it run on GPU?

0 포인트
eliopoulos
초보자
5,222 조회수

Here are the remaining input files.

0 포인트
Mark_Lewy
소중한 기여자 I
5,202 조회수

It built fine for me, however I got this series of errors running it:

LEVEL_ZERO message: Error: module creation failed
LEVEL_ZERO message: Target build log:
LEVEL_ZERO message:   ''
LEVEL_ZERO message:   'error: Total size of kernel arguments exceeds limit! Total arguments size: 2088, limit: 2048'
LEVEL_ZERO message:   'in kernel: 'MAIN__''
LEVEL_ZERO message:   'error: backend compiler failed build.'
LEVEL_ZERO message:   ''
LEVEL_ZERO message:   'error: Total size of kernel arguments exceeds limit! Total arguments size: 2088, limit: 2048'
LEVEL_ZERO message:   'in kernel: 'MAIN__''
LEVEL_ZERO message:   'error: backend compiler failed build.'
"PluginInterface" error: Failure to load binary image 0000027CEBD6A990 on device 0: Error in buildModules -1
omptarget error: Failed to load image Failed to load binary 0000027CEBD6A990
omptarget fatal error 0: Failed to load images on device '0'

I haven't offloaded before, but I suspect your loop is too complex to be offloaded to my Intel GPU.  Someone else may be able to provide other suggestions to fix this.

As you for your inability to compile your program, I suggest you confirm that you have all the HPC toolkit components installed and if that looks ok, try repairing your installation.

0 포인트
Ron_Green
중재자
5,192 조회수

GPUs have fixed memory size - in this example the data is too large.  Keep it simple, first get 100 element arrays to work then curb your data to fit the GPU.  

 

test that the driver is installed and working.  From a Intel Fortran Command Prompt window, run this command to make sure the driver is responding

 

sycl-ls 

 

 

0 포인트
eliopoulos
초보자
5,184 조회수
0 포인트
Ron_Green
중재자
5,170 조회수

compile and run from the Intel Fortran command prompt before moving to VS.  After downsizing the data sizes, run Mark's example to make sure core functionality is working.  And get rid of all the unnecessary /check and /warn options, traceback, etc.  Keep the compiler options to the simple qopenmp* options 

Get something simple working before throwing the question of Life the Universe and Everything to the GPU

0 포인트
eliopoulos
초보자
5,137 조회수

eliopoulos_0-1755624404053.png

Mark's example works. Is there anything wrong with my setup?

0 포인트
Ron_Green
중재자
4,998 조회수

There is an online document for OpenMP for C++ and Fortran https://www.intel.com/content/www/us/en/docs/oneapi/programming-guide/2025-1/c-c-or-fortran-with-openmp-offload-programming.html

 

I would recommend:
set LIBOMPTARGET_PLUGIN_PROFILE=T

When set, and you run your application, it will print the information for each offload kernel.  This is a way to verify that offload is actually occurring. 

Ron_Green_1-1755629270702.png

 

Also there are ENV vars to control output of debug info if something goes wrong in the offload

 

Ron_Green_0-1755629240441.png

 

eliopoulos
초보자
4,132 조회수

I still cannot compile and run my program on my Intel GPU. Is there anyone who can?

0 포인트
응답