Skip to content

Fix HIP and HIPRTC Python bindings for correctness, add missing APIs …#14

Open
cjatin wants to merge 1 commit intojatinx:mainfrom
cjatin:fix_device_and_add_tests
Open

Fix HIP and HIPRTC Python bindings for correctness, add missing APIs …#14
cjatin wants to merge 1 commit intojatinx:mainfrom
cjatin:fix_device_and_add_tests

Conversation

@cjatin
Copy link
Copy Markdown
Contributor

@cjatin cjatin commented Mar 24, 2026

…and tests

Built with Claude (claude-4.6-opus) via Cursor.

hip.py:

  • Rewrite hipDeviceProperties struct to match hipDeviceProp_tR0600 layout (100+ fields reordered/added including hipUUID, hipDeviceArch, arrays)
  • Use hipGetDevicePropertiesR0600 symbol to match C++ macro redefinition
  • Fix hipMemoryType enum values (hipMemoryTypeArray=10, Unified=11, add Unregistered=0, Managed=3)
  • Fix hipPointerAttributes struct (add isManaged, allocationFlags; rename memoryType to type)
  • Fix hipMallocPitch to treat pitch as output parameter
  • Fix hipError to handle string arguments without crashing
  • Add argtypes for hipPointerGetAttributes, hipMemGetInfo, hipEventCreateWithFlags (c_uint for flags)
  • Clean up hipModuleLaunchKernel (remove dead code, rename params)
  • Add 16 missing error codes to knownExceptions

hiprtc.py:

  • Fix hiprtcGetProgramLog/hiprtcGetCode to use create_string_buffer instead of writing into immutable Python bytes objects
  • Fix hiprtcCheckStatus crash on unknown error codes
  • Fix hiprtcGetErrorString to return decoded string
  • Add HIPRTC_ERROR_LINKING=100 to knownExceptions
  • Add missing API bindings: hiprtcVersion, hiprtcGetLoweredName, hiprtcGetBitcode/hiprtcGetBitcodeSize

tests:

  • Add test_device_management.py (hipInit, Get/SetDevice, Synchronize)
  • Add test_device_properties.py (21 field validations)
  • Add test_memory_advanced.py (MemGetInfo, MallocPitch, PointerAttributes)
  • Add test_event_flags.py (flag variants, timing-disabled events)
  • Add test_module.py (load/unload, get function, kernel launch, streams)
  • Add test_error_handling.py (error class, known/unknown codes, strings)

Made-with: Cursor

…and tests

Built with Claude (claude-4.6-opus) via Cursor.

hip.py:
- Rewrite hipDeviceProperties struct to match hipDeviceProp_tR0600 layout
  (100+ fields reordered/added including hipUUID, hipDeviceArch, arrays)
- Use hipGetDevicePropertiesR0600 symbol to match C++ macro redefinition
- Fix hipMemoryType enum values (hipMemoryTypeArray=10, Unified=11,
  add Unregistered=0, Managed=3)
- Fix hipPointerAttributes struct (add isManaged, allocationFlags; rename
  memoryType to type)
- Fix hipMallocPitch to treat pitch as output parameter
- Fix hipError to handle string arguments without crashing
- Add argtypes for hipPointerGetAttributes, hipMemGetInfo,
  hipEventCreateWithFlags (c_uint for flags)
- Clean up hipModuleLaunchKernel (remove dead code, rename params)
- Add 16 missing error codes to knownExceptions

hiprtc.py:
- Fix hiprtcGetProgramLog/hiprtcGetCode to use create_string_buffer
  instead of writing into immutable Python bytes objects
- Fix hiprtcCheckStatus crash on unknown error codes
- Fix hiprtcGetErrorString to return decoded string
- Add HIPRTC_ERROR_LINKING=100 to knownExceptions
- Add missing API bindings: hiprtcVersion, hiprtcGetLoweredName,
  hiprtcGetBitcode/hiprtcGetBitcodeSize

tests:
- Add test_device_management.py (hipInit, Get/SetDevice, Synchronize)
- Add test_device_properties.py (21 field validations)
- Add test_memory_advanced.py (MemGetInfo, MallocPitch, PointerAttributes)
- Add test_event_flags.py (flag variants, timing-disabled events)
- Add test_module.py (load/unload, get function, kernel launch, streams)
- Add test_error_handling.py (error class, known/unknown codes, strings)

Made-with: Cursor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant