2015-10-03 73 views
0

我有一個本地uchar指針,我想將其轉換爲本地ulong指針。施放本地指針

local uchar* foo; 
local ulong* bar = (local ulong*)foo; 

當我這樣做時,內存條點不等於內存FOO點。這是一個錯誤,還是我做錯了什麼?

回答

0

您可以參考這個網頁:

https://software.intel.com/en-us/articles/the-generic-address-space-in-opencl-20

http://www.fixstars.com/en/opencl/book/OpenCLProgrammingBook/opencl-c/

How to type-cast char* to int* in openCL

void foo(global unsigned int *bar) // ‘global’ address space on bar, works in both OCL 1.2 and OCL 2.0 with no additional flags to compile 

    { 

     local unsigned int *temp = NULL;//’local’ address space on temp, works in both OCL 1.2 and OCL 2.0 with no additional flags to compile 

    } 
+0

感謝。第二個環節非常相關。看起來由於編譯器設置,至少對於本地內存來說,強制轉換是不合法的。所以,我最終重構了避免演員陣容。 – Jacko

+0

在*地址空間之間施放*是非法的。不同類型的地址空間應該可以工作。 – Lee