Skip to content

Commit

Permalink
simple comgr test
Browse files Browse the repository at this point in the history
  • Loading branch information
geohot committed Jan 26, 2024
1 parent c1c60a6 commit 06bd12e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 5 additions & 2 deletions generate_hip.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash -e
clang2py /opt/rocm/include/hip/hip_ext.h /opt/rocm/include/hip/hiprtc.h /opt/rocm/include/hip/hip_runtime_api.h /opt/rocm/include/hip/driver_types.h --clang-args="-D__HIP_PLATFORM_AMD__ -I/opt/rocm/include -x c++" -o gpuctypes/hip.py -l /opt/rocm/lib/libamdhip64.so
clang2py /opt/rocm/include/hip/hip_ext.h /opt/rocm/include/hip/hiprtc.h \
/opt/rocm/include/hip/hip_runtime_api.h /opt/rocm/include/hip/driver_types.h \
--clang-args="-D__HIP_PLATFORM_AMD__ -I/opt/rocm/include -x c++" -o gpuctypes/hip.py -l /opt/rocm/lib/libamdhip64.so
echo "hipDeviceProp_t = hipDeviceProp_tR0600" >> gpuctypes/hip.py
echo "hipGetDeviceProperties = hipGetDevicePropertiesR0600" >> gpuctypes/hip.py
grep FIXME_STUB gpuctypes/hip.py || true
Expand All @@ -9,6 +11,7 @@ grep FIXME_STUB gpuctypes/hip.py || true
#sed -i "s\ctypes.CDLL('/opt/rocm/lib/libamdhip64.so')\ctypes.CDLL(ctypes.util.find_library('amdhip64'))\g" gpuctypes/hip.py
python3 -c "import gpuctypes.hip"

clang2py /opt/rocm/include/amd_comgr/amd_comgr.h --clang-args="-D__HIP_PLATFORM_AMD__ -I/opt/rocm/include -x c++" -o gpuctypes/comgr.py -l /opt/rocm/lib/libamd_comgr.so
clang2py /opt/rocm/include/amd_comgr/amd_comgr.h \
--clang-args="-D__HIP_PLATFORM_AMD__ -I/opt/rocm/include -x c++" -o gpuctypes/comgr.py -l /opt/rocm/lib/libamd_comgr.so
grep FIXME_STUB gpuctypes/comgr.py || true
python3 -c "import gpuctypes.comgr"
5 changes: 5 additions & 0 deletions test/test_hip.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import unittest
import ctypes
import gpuctypes.hip as hip
import gpuctypes.comgr as comgr
from helpers import CI, expectedFailureIf, cuda_compile

def check(status):
Expand Down Expand Up @@ -29,6 +30,10 @@ def test_compile(self):
prg = cuda_compile("int test() { return 42; }", ["--offload-arch=gfx1100"], HIPCompile, check)
assert len(prg) > 10

def test_comgr(self):
status = comgr.amd_comgr_create_action_info(ctypes.byref(action_info := comgr.amd_comgr_action_info_t()))
assert status == 0

class TestHIPDevice(unittest.TestCase):
@expectedFailureIf(CI)
def test_malloc(self):
Expand Down

0 comments on commit 06bd12e

Please sign in to comment.