Edwin
Edwin

Reputation: 3

Type conversion in opencl

I want to convert 'unsigned char' 'uchar16'. At first, I Direct convert it, but it run error.

uchar16* out;
unsigned char ciphertext[16];
/*
* 
*/
out[0] = (uchar16)(ciphertext[0], ciphertext[1], ciphertext[2], ciphertext[3], 
        ciphertext[4], ciphertext[5], ciphertext[6], ciphertext[7], 
        ciphertext[8], ciphertext[9], ciphertext[10], ciphertext[11], 
        ciphertext[12], ciphertext[13], ciphertext[14], ciphertext[15]);

When I use real value instead of the variable, it runs.

out[0] = (uchar16)(0x2B, 0x7E, 0x15, 0x16, 
    0x28, 0xAE, 0xD2, 0xA6, 
    0xAB, 0xF7, 0x15, 0x88, 
    0x09, 0xCF, 0x4F, 0x3C);

I searched in Google and Stackoverflow, and I did not find the answer.

Upvotes: 0

Views: 1196

Answers (2)

CaptainObvious
CaptainObvious

Reputation: 2565

For vector conversion in OpenCL there is the suite of functions:

convert_destType(sourceType)

See point 6.2.3 of the standard (v1.2). So in your case it would be:

uchar16 out = convert_uchar16(ciphertext);

Upvotes: 1

Eric Bainville
Eric Bainville

Reputation: 9906

What is the error you get?

It is simpler and generally more efficient to call vload16 in this case:

uchar16 u = vload16(0,ciphertext);

Upvotes: 1

Related Questions