-
Notifications
You must be signed in to change notification settings - Fork 41
[UIL] Update python ctypes bindings to match revised deviceHandle and Ipc/Stream APIs #301
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
base: main
Are you sure you want to change the base?
Conversation
…gcx.h to ensure consistent API behavior
|
@gemini-code-assist please review this pull request in details |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates the Python ctypes bindings to align with the revised C header API (flagcx.h) for device handles, streams, and IPC memory operations.
Key Changes:
- Refactored
flagcxStream_tfrom a custom structure to an opaque pointer type (c_void_p) to match the C API definition - Added IPC memory handle operations and
hostGetDevicePointerto theflagcxDeviceHandlestructure - Updated stream handling in
adaptor_stream_copyto work with the new pointer-based stream type
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
mikethegoblin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
ceci3
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
@gemini-code-assist please review this pull request in details |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| EVENT_SYNCHRONIZE_FUNCTYPE = ctypes.CFUNCTYPE(flagcxResult_t, flagcxEvent_t) | ||
| EVENT_QUERY_FUNCTYPE = ctypes.CFUNCTYPE(flagcxResult_t, flagcxEvent_t) | ||
|
|
||
| IPC_MEM_HANDLE_CREATE_FUNCTYPE = ctypes.CFUNCTYPE(flagcxResult_t, ctypes.POINTER(flagcxIpcMemHandle_t), ctypes.POINTER(ctypes.c_size_t)) |
Copilot
AI
Nov 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The IPC_MEM_HANDLE_CREATE_FUNCTYPE signature appears inconsistent with the C header. According to flagcx.h line 158-159, ipcMemHandleCreate takes flagcxIpcMemHandle_t *handle (pointer to pointer) and size_t *size, but flagcxIpcMemHandle_t is already defined as ctypes.c_void_p (line 22), which is a single pointer. The first parameter should be ctypes.POINTER(ctypes.c_void_p) to match the double-pointer indirection.
| IPC_MEM_HANDLE_GET_FUNCTYPE = ctypes.CFUNCTYPE(flagcxResult_t, flagcxIpcMemHandle_t, ctypes.c_void_p) | ||
| IPC_MEM_HANDLE_OPEN_FUNCTYPE = ctypes.CFUNCTYPE(flagcxResult_t, flagcxIpcMemHandle_t, ctypes.POINTER(ctypes.c_void_p)) |
Copilot
AI
Nov 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter types for IPC_MEM_HANDLE_GET_FUNCTYPE and IPC_MEM_HANDLE_OPEN_FUNCTYPE are swapped. According to flagcx.h lines 160-162, ipcMemHandleGet takes (flagcxIpcMemHandle_t handle, void *devPtr) while ipcMemHandleOpen takes (flagcxIpcMemHandle_t handle, void **devPtr). The current definitions have the pointer indirection reversed - line 71 should have ctypes.POINTER(ctypes.c_void_p) as the second parameter, and line 72 should have ctypes.c_void_p.
| IPC_MEM_HANDLE_GET_FUNCTYPE = ctypes.CFUNCTYPE(flagcxResult_t, flagcxIpcMemHandle_t, ctypes.c_void_p) | |
| IPC_MEM_HANDLE_OPEN_FUNCTYPE = ctypes.CFUNCTYPE(flagcxResult_t, flagcxIpcMemHandle_t, ctypes.POINTER(ctypes.c_void_p)) | |
| IPC_MEM_HANDLE_GET_FUNCTYPE = ctypes.CFUNCTYPE(flagcxResult_t, flagcxIpcMemHandle_t, ctypes.POINTER(ctypes.c_void_p)) | |
| IPC_MEM_HANDLE_OPEN_FUNCTYPE = ctypes.CFUNCTYPE(flagcxResult_t, flagcxIpcMemHandle_t, ctypes.c_void_p) |
PR Category
UIL
PR Types
Bug Fixes
PR Description
This PR updates the Python ctypes wrapper to accurately reflect the latest flagcx.h device-handle and stream-related definitions.
Key Updates