Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update runtime for ROCm6.0 (SWDEV-434155) #38

Merged
merged 6 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pretest-rocm-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ DEBIAN_FRONTEND=noninteractive apt-get -y install python3.9-dev python3-pip

hipconfig

python3.9 -m pip install -U pip wheel
pip3 install -U pip wheel

export ROCM_HOME="/opt/rocm"
export HCC_AMDGPU_TARGET="gfx900"
Expand Down
4 changes: 2 additions & 2 deletions cupy_backends/cuda/api/_runtime_typedef.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions cupy_backends/cuda/api/runtime.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,6 @@ cpdef getDeviceProperties(int device):
properties['clockInstructionRate'] = props.clockInstructionRate
properties['maxSharedMemoryPerMultiProcessor'] = (
props.maxSharedMemoryPerMultiProcessor)
properties['gcnArch'] = props.gcnArch
properties['hdpMemFlushCntl'] = <intptr_t>(props.hdpMemFlushCntl)
properties['hdpRegFlushCntl'] = <intptr_t>(props.hdpRegFlushCntl)
properties['memPitch'] = props.memPitch
Expand Down Expand Up @@ -328,6 +327,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
Expand Down Expand Up @@ -697,13 +698,13 @@ cpdef PointerAttributes pointerGetAttributes(intptr_t ptr):
cdef _PointerAttributes attrs
status = cudaPointerGetAttributes(&attrs, <void*>ptr)
check_status(status)
IF CUPY_CUDA_VERSION > 0:
IF CUPY_CUDA_VERSION > 0 or CUPY_HIP_VERSION > 60000000:
return PointerAttributes(
attrs.device,
<intptr_t>attrs.devicePointer,
<intptr_t>attrs.hostPointer,
attrs.type)
ELIF CUPY_HIP_VERSION > 0:
ELIF 0 < CUPY_HIP_VERSION < 60000000:
return PointerAttributes(
attrs.device,
<intptr_t>attrs.devicePointer,
Expand Down
19 changes: 18 additions & 1 deletion cupy_backends/hip/cupy_hip_runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */:
Expand All @@ -281,7 +296,9 @@ cudaError_t cudaPointerGetAttributes(cudaPointerAttributes *attributes,
/* we don't care the rest of possibilities */
return status;
}
} else {
}
#endif
else {
return status;
}
}
Expand Down