Search code examples
ccudabit-manipulationuint

Issue working with uint2 and CUDA


Recently I started working with CUDA and Ethereum and I found a little bit of code snipet on a function that when I try to port to a cuda file I get some errors.

Here is the code snippet:

void keccak_f1600_round(uint2* a, uint r, uint out_size)
{

#if !__ENDIAN_LITTLE__
    for (uint i = 0; i != 25; ++i)
        a[i] = make_uint2(a[i].y, a[i].x);
#endif

uint2 b[25];
uint2 t;

// Theta
b[0] = a[0] ^ a[5] ^ a[10] ^ a[15] ^ a[20];

#if !__ENDIAN_LITTLE__
    for (uint i = 0; i != 25; ++i)
        a[i] = make_uint2(a[i].y, a[i].x);
#endif

}

The error I am getting concern the b[0] line and is:

error: no operator "^=" matches these operands operand types are: uint2 ^= uint2

TO be honest I don't have a lot of experience with uint2 and cuda and that is why I am asking what should I do to correct this issue.


Solution

  • uint2 is simply a struct, you'll need to implement ^ using a[].x and a[].y. I couldn't find where the builtin declarations are but Are there advantages to using the CUDA vector types? has a good description of their use.