Skip to content

hipfort got easier #1

@domcharrier

Description

@domcharrier

FYI We added additional HIP and ROCm interfaces that allow to pass pointer and target (array) variables
instead of type(c_ptr) and number of bytes. (Everything is still compatible to gfortran.)

When you have the following in CUDA Fortran:

real, device :: x_d(N), y_d(N)`

you can write the following now with hipfort:

real, pointer :: x_d(:), y_d(:)`

ierr = hipMalloc(x_d,N)
ierr = hipMalloc(y_d,N)

There are further some shortcuts such as

real :: x_h(N), y_h(N)`
real, pointer :: x_d(:), y_d(:), z_d(:)

ierr = hipMalloc(x_d,mold=x_h) ! create with bounds of x_h
ierr = hipMalloc(y_d,source=y_h) ! create with bounds of y_h and perform copy from host array y_h to device array y_d
ierr = hipMalloc(z_d,dsource=y_d) ! create with bounds of y_d and perform copy from device array y_d to device array z_d

ierr = hipMemcpy(z_h, z_d, hipMemcpyDeviceToHost) ! Memcpy parameter 'N' is optional if full array should be copied

Take a look at the new f2008 examples:

https://github.com/ROCmSoftwarePlatform/hipfort/tree/master/test/f2008

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions