Replies: 3 comments
-
I am not sure if that assessment is correct and here are my reasons:
Among the three mentioned, I think the only candidate for converting the indices type to |
Beta Was this translation helpful? Give feedback.
-
There are floating point, signed integer, unsigned integer, and complex types. Using the process of elimination, floating point types are bad for indexing because they can have negative values (-1,-2,-3) and they can have non integer values (1.1,2.4,5.3). Therefore, floating point can cause many errors and should not be used for indexing. Complex data types are bad for indexing because they have the same disadvantages as floating point. They should not be used for indexing. For signed integer types, they can have negative values (-1,-2,-3) which can cause the index to go out of the array's memory region and crash GPUs and CPUs. They should not be used for indexing. For the unsigned integer types, there are u8,u16,u32,u64, and usize. u32 is bad because you can only access 4294967296 elements. Assuming you have RTX 3090 (24 GB RAM) and you are using a 32 bit array, at most you can only access 17.18 GB out of the 24 GB. That means you can't use all of your GPU. usize is bad because it depends on the ISA of the machine. If you write your program and debug on AMD machine with an x86_64 ISA, then usize will be u64 and it can access 1.8446744e+19 elements. If you recompile it on NVidia jetson with ARM 32 bit ISA, the program's usize will be u32 and it can't access anything above 4294967296 elements. This will introduce indexing errors in your program. This defeats arrayfire's "Code once, run anywhere!". By the process of elimination, u64 is the only data type that doesn't cause run-time errors in indexing. The functions can be rewritten to only accept u64 and can be internally casted to any other datatype. |
Beta Was this translation helpful? Give feedback.
-
I think I wasn't clear and/or elaborate enough earlier.
|
Beta Was this translation helpful? Give feedback.
-
Description
Arrayfire::row, arrayfire::col uses u64 to index arrays
index_gen uses f32, f64, u32, u64 to index arrays
arrayfire::sparse uses i32 to index arrays
It is a complete mess of indexing. It is easier to change all indexing to just u64 because negative values might cause errors.
Beta Was this translation helpful? Give feedback.
All reactions