2013-05-04 111 views
0

我想轉換'unsigned char''uchar16'。起初,我直接轉換它,但它運行錯誤。opencl中的類型轉換

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]); 

當我使用實際值而不是變量時,它運行。

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

我在谷歌和Stackoverflow搜索,我沒有找到答案。

+1

你沒有爲「out」分配任何內存。試試「uchar16 out [1];」代替。 – 2013-05-04 11:16:11

回答

1

對於OpenCL的矢量轉換有功能的套房:

convert_destType(sourceType) 

見點6.2。標準3(v1.2)。所以在你的情況下,它將是:

uchar16 out = convert_uchar16(ciphertext); 
1

你得到的錯誤是什麼?

這是更簡單的,並且通常更高效的調用vload16在這種情況下:

uchar16 u = vload16(0,ciphertext);