If I want to convert an array of chars into an array of floats, or vice versa, on the device, do I have the right idea with the following functions?
Will this work? Is there a more efficient way to do this? I’m not sure I understand how to optimize memory accesses, especially when the data types are different sizes (8 bit vs 32 bit units)
If I want to convert an array of chars into an array of floats, or vice versa, on the device, do I have the right idea with the following functions?
Will this work? Is there a more efficient way to do this? I’m not sure I understand how to optimize memory accesses, especially when the data types are different sizes (8 bit vs 32 bit units)
You may want to multiply / divide by CHAR_MAX to normalise the floats (depending on your app)
If there’s a char4 type, I’d use that, and map it to a float4. Each thread converts 4 values and writes 4 values, and you get pretty good speed I think.
void charsToFloats(char4* src, float4 *dest, int numItems)
You may want to multiply / divide by CHAR_MAX to normalise the floats (depending on your app)
If there’s a char4 type, I’d use that, and map it to a float4. Each thread converts 4 values and writes 4 values, and you get pretty good speed I think.
void charsToFloats(char4* src, float4 *dest, int numItems)