From 2e31c830e1324a2055455d802c9b668fef3c3c1f Mon Sep 17 00:00:00 2001 From: AdrianAbeyta Date: Tue, 28 Nov 2023 22:22:28 +0000 Subject: [PATCH 1/5] Fix runtime compile issues for ROCm6.0 --- cupy_backends/cuda/api/runtime.pyx | 7 ++++--- cupy_backends/hip/cupy_hip_runtime.h | 19 ++++++++++++++++++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/cupy_backends/cuda/api/runtime.pyx b/cupy_backends/cuda/api/runtime.pyx index 8faff9fca94..b0d84de9548 100644 --- a/cupy_backends/cuda/api/runtime.pyx +++ b/cupy_backends/cuda/api/runtime.pyx @@ -294,7 +294,6 @@ cpdef getDeviceProperties(int device): properties['clockInstructionRate'] = props.clockInstructionRate properties['maxSharedMemoryPerMultiProcessor'] = ( props.maxSharedMemoryPerMultiProcessor) - properties['gcnArch'] = props.gcnArch properties['hdpMemFlushCntl'] = (props.hdpMemFlushCntl) properties['hdpRegFlushCntl'] = (props.hdpRegFlushCntl) properties['memPitch'] = props.memPitch @@ -327,6 +326,8 @@ cpdef getDeviceProperties(int device): arch['has3dGrid'] = props.arch.has3dGrid arch['hasDynamicParallelism'] = props.arch.hasDynamicParallelism properties['arch'] = arch + IF 0 < CUPY_HIP_VERSION < 310: #gcnArchName used after ROCm 3.1+ + properties['gcnArch'] = props.gcnArch IF CUPY_HIP_VERSION >= 310: properties['gcnArchName'] = props.gcnArchName properties['asicRevision'] = props.asicRevision @@ -696,13 +697,13 @@ cpdef PointerAttributes pointerGetAttributes(intptr_t ptr): cdef _PointerAttributes attrs status = cudaPointerGetAttributes(&attrs, ptr) check_status(status) - IF CUPY_CUDA_VERSION > 0: + IF CUPY_CUDA_VERSION > 0 or CUPY_HIP_VERSION > 60000000: return PointerAttributes( attrs.device, attrs.devicePointer, attrs.hostPointer, attrs.type) - ELIF CUPY_HIP_VERSION > 0: + ELIF 0 < CUPY_HIP_VERSION < 60000000: return PointerAttributes( attrs.device, attrs.devicePointer, diff --git a/cupy_backends/hip/cupy_hip_runtime.h b/cupy_backends/hip/cupy_hip_runtime.h index 51a54323ebc..0d1eb208528 100644 --- a/cupy_backends/hip/cupy_hip_runtime.h +++ b/cupy_backends/hip/cupy_hip_runtime.h @@ -269,6 +269,21 @@ cudaError_t cudaMemPrefetchAsync(const void *devPtr, size_t count, cudaError_t cudaPointerGetAttributes(cudaPointerAttributes *attributes, const void* ptr) { cudaError_t status = hipPointerGetAttributes(attributes, ptr); +#if HIP_VERSION >= 60000000 + if (status == cudaSuccess) { + switch (attributes->type) { + case 0 /* hipMemoryTypeHost */: + attributes->type = (hipMemoryType)1; /* cudaMemoryTypeHost */ + return status; + case 1 /* hipMemoryTypeDevice */: + attributes->type = (hipMemoryType)2; /* cudaMemoryTypeDevice */ + return status; + default: + /* we don't care the rest of possibilities */ + return status; + } + } +#else if (status == cudaSuccess) { switch (attributes->memoryType) { case 0 /* hipMemoryTypeHost */: @@ -281,7 +296,9 @@ cudaError_t cudaPointerGetAttributes(cudaPointerAttributes *attributes, /* we don't care the rest of possibilities */ return status; } - } else { + } +#endif + else { return status; } } From 9a332306e01f869d7bd2505bb1b801f6bdc66b7c Mon Sep 17 00:00:00 2001 From: AdrianAbeyta Date: Tue, 28 Nov 2023 22:52:47 +0000 Subject: [PATCH 2/5] Fix conditionals for ROCm6.0 --- cupy_backends/cuda/api/_runtime_typedef.pxi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cupy_backends/cuda/api/_runtime_typedef.pxi b/cupy_backends/cuda/api/_runtime_typedef.pxi index 9560b8260cc..b365f3321cd 100644 --- a/cupy_backends/cuda/api/_runtime_typedef.pxi +++ b/cupy_backends/cuda/api/_runtime_typedef.pxi @@ -131,13 +131,13 @@ cdef extern from *: ctypedef struct _MemPoolProps 'cudaMemPoolProps': pass # for HIP & RTD - IF CUPY_CUDA_VERSION > 0: + IF CUPY_CUDA_VERSION > 0 or CUPY_HIP_VERSION > 60000000: ctypedef struct _PointerAttributes 'cudaPointerAttributes': int type int device void* devicePointer void* hostPointer - ELIF CUPY_HIP_VERSION > 0: + ELIF 0 < CUPY_HIP_VERSION < 60000000: ctypedef struct _PointerAttributes 'cudaPointerAttributes': int memoryType int device From 8543331f7d489a48596c48cd448a2a46e21f47ce Mon Sep 17 00:00:00 2001 From: AdrianAbeyta Date: Tue, 28 Nov 2023 23:22:39 +0000 Subject: [PATCH 3/5] fix flake8 cython issues --- cupy_backends/cuda/api/_runtime_typedef.pxi | 2 +- cupy_backends/cuda/api/runtime.pyx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cupy_backends/cuda/api/_runtime_typedef.pxi b/cupy_backends/cuda/api/_runtime_typedef.pxi index b365f3321cd..a4a129e0087 100644 --- a/cupy_backends/cuda/api/_runtime_typedef.pxi +++ b/cupy_backends/cuda/api/_runtime_typedef.pxi @@ -131,7 +131,7 @@ cdef extern from *: ctypedef struct _MemPoolProps 'cudaMemPoolProps': pass # for HIP & RTD - IF CUPY_CUDA_VERSION > 0 or CUPY_HIP_VERSION > 60000000: + IF CUPY_CUDA_VERSION > 0 or CUPY_HIP_VERSION > 60000000: ctypedef struct _PointerAttributes 'cudaPointerAttributes': int type int device diff --git a/cupy_backends/cuda/api/runtime.pyx b/cupy_backends/cuda/api/runtime.pyx index b0d84de9548..1d7732e0174 100644 --- a/cupy_backends/cuda/api/runtime.pyx +++ b/cupy_backends/cuda/api/runtime.pyx @@ -326,7 +326,7 @@ cpdef getDeviceProperties(int device): arch['has3dGrid'] = props.arch.has3dGrid arch['hasDynamicParallelism'] = props.arch.hasDynamicParallelism properties['arch'] = arch - IF 0 < CUPY_HIP_VERSION < 310: #gcnArchName used after ROCm 3.1+ + IF 0 < CUPY_HIP_VERSION < 310: # gcnArchName used after ROCm 3.1+ properties['gcnArch'] = props.gcnArch IF CUPY_HIP_VERSION >= 310: properties['gcnArchName'] = props.gcnArchName From 61e60270bcd0ae8ad3befd081f2882e1957f68c4 Mon Sep 17 00:00:00 2001 From: Kenichi Maehashi Date: Tue, 18 Jul 2023 02:03:12 +0000 Subject: [PATCH 4/5] remove explicit cython installation --- .github/workflows/pretest-rocm-test.sh | 3 +-- .github/workflows/pretest.yml | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/pretest-rocm-test.sh b/.github/workflows/pretest-rocm-test.sh index acb130500ba..9da45c2dcef 100644 --- a/.github/workflows/pretest-rocm-test.sh +++ b/.github/workflows/pretest-rocm-test.sh @@ -8,8 +8,7 @@ DEBIAN_FRONTEND=noninteractive apt-get -y install python3-pip python3-dev hipconfig -pip3 install -U pip wheel -pip3 install cython +python3.9 -m pip install -U pip wheel export ROCM_HOME="/opt/rocm" export HCC_AMDGPU_TARGET="gfx900" diff --git a/.github/workflows/pretest.yml b/.github/workflows/pretest.yml index 13a91f999cc..ca5339579a9 100644 --- a/.github/workflows/pretest.yml +++ b/.github/workflows/pretest.yml @@ -67,7 +67,6 @@ jobs: - name: Build run: | pip install -U pip wheel - pip install cython READTHEDOCS=True pip install -v -e . ccache --max-size 0.5Gi --cleanup --show-stats From 09d53dd8e2620c40e68b8ab553c111faa00fb863 Mon Sep 17 00:00:00 2001 From: AdrianAbeyta Date: Wed, 29 Nov 2023 04:24:00 +0000 Subject: [PATCH 5/5] Update CI --- .github/workflows/pretest-rocm-test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pretest-rocm-test.sh b/.github/workflows/pretest-rocm-test.sh index 9da45c2dcef..d661928d1aa 100644 --- a/.github/workflows/pretest-rocm-test.sh +++ b/.github/workflows/pretest-rocm-test.sh @@ -8,7 +8,7 @@ DEBIAN_FRONTEND=noninteractive apt-get -y install python3-pip python3-dev hipconfig -python3.9 -m pip install -U pip wheel +pip3 install -U pip wheel export ROCM_HOME="/opt/rocm" export HCC_AMDGPU_TARGET="gfx900"