I’m trying to convert data from 10bit to 16bit, so I use bitfield struct to help solve this problem, it works well at CPU.
In order to use CUDA acceleration, I modified this code.the device is nvidia jetson tx1, arch=compute_53.
But Some error happened when I compiled code.
it seems like cuda or nvcc can not support bitfield.
how should I solve this problem?
*.hpp (col. 8): error:“Bitfields and field types containing bitfields are not supported in packed structures and unions for device compilation!”
Based on decades of dealing with bit-fiddling code and several years involvement with embedded programming projects in telecom I would say that bitfields should never be used. They are one of the more common sources of frustration when trying to craft portable code. It starts with variances allowed by the language standards and continues to implementation artifacts like the one you appear to be encountering.
Use the standard assortment of masks, shifts, logic operations to accomplish the extraction and compositing of data. You can wrap the functionality in macros or inline functions as you see fit.
I am a bit surprised that there are restrictions on bitfields in CUDA, as I do not readily understand why they would be difficult to support. Have you checked the CUDA documentation to see whether it specifies exactly what uses of bitfields are off limits? I cannot imagine bitfields are “outlawed” all together, but maybe they are …
A bit of general advice: Questions about NVIDIA’s embedded platforms are best asked in the sub-forums dedicated to those platforms. You are likely to receive better and faster answers there. For Jetson TX1: Jetson TX1 - NVIDIA Developer Forums
I didn’t checked the CUDA documentation. From the compile error I think it not support bitfield.I refactored the code to use the shift calculation to do it