One of the arguments for CL12.clCreateImage()
is a ByteBuffer
containing this struct. I will be using the method described in OpenCL kernel arguments to pass the struct but am not certain what to use for the arguments that are of type size_t
. From Java,when I put the arguments into the ByteBuffer
, should I use an int
(signed 32 bit) if I am using a 32-bit system or a long
(signed 64 bits) if I am using a 64-bit?
Asked
Active
Viewed 900 times
1
1 Answers
-2
a size_t type is an "unsigned int". You can definitely use int type but make sure it is not a negative number, otherwise it makes no sense.
When considering the above, You should not worry about 32 and 64 bit systems and you should not need to use a long
so you can do something like
int param = value; //this is the value to pass
if (param >= 0) {
pclFunc((size_t)param)
} else {
//see how you want to handle this
}

Moataz Elmasry
- 2,509
- 4
- 27
- 37
-
Are you sure size_t is always 32bits ? AFAIK size_t is the same size as int and then could be 0 to 2^64 - 1 on a 64bits system. – Pragmateek Jan 07 '13 at 20:35
-
apologies, size_t is always unsigned int size, regardless which size the int is – Moataz Elmasry Jan 07 '13 at 20:37
-
How do I determine the size of an unsigned int? – vandale Jan 07 '13 at 21:10
-
usigned int has the exact same size as a signed int.they only differ in range. so unsgned int in 32 bit system has range 0-2^32, while in singed system has the range -2^31-2^31, because 1 bit is reserved for the +- sign – Moataz Elmasry Jan 07 '13 at 21:52
-
I'm not close to my work pc now, but I bet u that size_t is defined as: "typedef usigned int size_t" – Moataz Elmasry Jan 07 '13 at 21:55