ctypes struct alignment specification
Chris
chrisuchytil1234 at gmail.com
Tue Nov 10 19:33:10 EST 2020
I am working on a CUDA python API using ctypes. Within CUDA there are vector type structs defined (float2, float3, float4, int2, int3, int4, ...), all of which have an alignment specification (example of how this is specified https://stackoverflow.com/questions/12778949/cuda-memory-alignment/12779757) . I want to include these structs in the Python api but as far as I can tell, ctypes does not have a way to specify a structure's alignment in the same fashion (the #pragma pack(n) alignment feature that ctypes does support does not do the same thing). If the alignment specification is omitted on the Python side, the structure's alignment can be mismatched between the host (CPU) and device (GPU) causing segfaults/etc. . Is this something that could be added to ctypes or is it not feasible/possible?
More information about the Python-list
mailing list