332 ensure portability of openmp target backend across nividia and amd gpus - #335
Conversation
Need to replace stored Fortran device arrays with c_ptr that we then get the Fortran pointer for on the device
|
I did some investigation and it seems that for the Cray compiler, the device pointer MUST be a dummy argument. So, having something like this does the trick: EDIT: Sorry, I am probably experiencing a different issue as I am compiling with Cray 16 on Archer2. |
|
@pbartholomew08 What facilities are you using to compile with cce 20 and flang22? I am trying to compile on ARCHER2 and the compilation fails because ROCM_PATH can't be found. Rather than spending time to figure out how to compile on ARCHER2, I think I am better off to use a more recent facility. |
|
Hi @CFD-Xing - I've not had a chance to try your suggested changes, I'll hopefully do tomorrow. I'm building using the latest flang I can get from AMD on Dirac, and I think if you log into a GPU node on ARCHER2 you should get CCE 20 for the Cray compilers |
|
@pbartholomew08 Ok thanks for the information. EDIT: I don't think I can access GPU node on ARCHER2. PS: You can use my patch to give a quick try if you want. |
|
Thanks @CFD-Xing - I've tried building with the patch on ARCHER2 using the Cray compiler and still have the issue around offloading |
|
@pbartholomew08 I finally managed to sort out how to compile on ARCHER2. The previous error that I was seeing was probably due to using CCE 16 instead of CCE 20. And after looking into it, it seems that the Cray compiler does not support calling c_f_pointer inside a OMP TARGET construct... EDIT: Spend a large part of the day looking into this and I think that there is no way around with the Cray compiler. Here is a patch fixing a bug and moves the |
| integer, intent(in) :: dims(3) | ||
|
|
||
| call c_f_pointer(self%dev_ptr, self%data_tgt, shape=dims) | ||
| if (product(dims) < self%n) then |
There was a problem hiding this comment.
This should be if (product(dims) <= self%n) then
|
@pbartholomew08 With some help from Claude, I think I managed to have something working with both NVHPC and Cray: patch2.patch |
I'm opening this for visibility/discussion.
I think this implements the changes suggested by #332. However, with this I'm no longer able to compile the code with Cray (cce 20) or AMD (flang 22) compilers due to
call c_f_pointernot being offloaded andis_device_addrnot being supported, respectively. Of course, there may be a mistake in the implementation in which case I'll correct it and retest.