11 Replies Latest reply on Aug 22, 2011 7:12 AM by diapolo

    kernel output-buffer as ulong (64-Bit)?

    diapolo

      Is it allowed to write into global memory if it is defined as __global ulong *? I want to pack 2 uints into 1 ulong and write this in global memory and reverse this in the host application.

      const ulong a = (ulong)(Var1 << 32);
      const ulong b = ((Var2 & 0xFFFFFFFFU;
      const ulong Var64 = a | b;

      output[0] = Var64;

      Currently it seems as if only 32 Bits of data are written into the output-buffer. On host application side the buffer is of type uint64 (numpy - Python).

      Thanks,

      Dia

        • kernel output-buffer as ulong (64-Bit)?
          MicahVillmow
          Why not just use uint2 a = some value;
          output[0] = as_ulong(a);
            • kernel output-buffer as ulong (64-Bit)?
              diapolo

               

              Originally posted by: MicahVillmow Why not just use uint2 a = some value; output[0] = as_ulong(a);


              Thanks, I didn't know, that this can be used for packing :). But the problem is, that my host application always seems to only get 32 Bits of data.

              But the question if it's possible to write an ulong to global memory is yes, right? Any idea what could cause a bit-loss here?

              Dia

            • kernel output-buffer as ulong (64-Bit)?
              MicahVillmow
              diapolo,
              Yeah, you can write ulong to memory. Make sure that you are using the correct types on the host side. Instead of unsigned long, use cl_ulong. Some systems have unsigned long as 32bits.
                • kernel output-buffer as ulong (64-Bit)?
                  diapolo

                  Hey Micah,

                  I figured out, that he host application is doing it's job pretty fine. The buffer consists of an uint64 array.

                  But there seems to be some kind of weird bug in the OpenCL runtime, please look at this 2 code samples:

                   

                  1.

                  __constant constVal = 0xec9fcd13;

                  uint2 Result = (uint2)(((Vec2a.x == constVal) * Vec2b.x), ((Vec2a.y == constVal) * Vec2b.y));
                  output[1023 & Result.x] = ((ulong)Result.x << 32) | (Result.y & 0xFFFFFFFFUL);

                  This doesn't work as it should, there are only results in the hi-part of the output-buffer element. lo-part is always 0!

                  2.

                  __constant constVal = 0xec9fcd13;

                  uint2 Result = (uint2)(((Vec2a.x == constVal) * Vec2b.x), ((Vec2a.y == constVal) * Vec2b.y));
                  output[1023 & Result.x] = ((ulong)Result.x << 32) | (5 & 0xFFFFFFFFUL);

                  This works as expected, sometimes there is something in the hi-part, but 5 is always in the lo part!

                  What is that? I need this to work :-/.

                   

                  Thanks,

                  Dia