This project is read-only.

Problem on storing ulong

Nov 27, 2015 at 3:29 PM
Trying to implement the followwing method
    public static ulong ByteArrayToUlong(int n, byte[] array)
        int i;
        ulong k = 0;
        for (i = 0; i < n; k += array[i++])
            k <<= 8;
        return k;
I realised that there is a problem on storing ulong numbers. It keeps only the 32 bits e.g. 0x32877FB0A17C40 it will convert it to 0xffffffffB0A17C40.
Does anyone else face something like it ??
Nov 28, 2015 at 2:11 PM
Yes, the problem here is the bit shift on ulongs, which are being cast to ints by cudafy when generating the c code. It's a bug of the cudafy translator.
The easiest way around it is to write a DummyFunction in cudafy, which functions as a wrapper for the shl function. For info on dummy functions, check