GEOS-DEV / LvArray

Portable HPC Containers (C++)
BSD 3-Clause "New" or "Revised" License
47 stars 10 forks source link

Rework `Macros.hpp` for devices #303

Open tbeltzun opened 1 year ago

tbeltzun commented 1 year ago

The MSG argument fo the LVARRAY_ERROR_IF is useless when used on a GPU (device):

https://github.com/GEOS-DEV/LvArray/blob/86af5bfb5204d94dd7b1f4bcf98a37b8de9a630c/src/Macros.hpp#L148

For example, the expression in https://github.com/GEOS-DEV/LvArray/blob/86af5bfb5204d94dd7b1f4bcf98a37b8de9a630c/src/ArraySlice.hpp#L56-L57

is printed as Array Bounds Check Failed: index= << index << m_dims[0]= << m_dims[0] in the stacktraces (unevaluated, hence not helpful).

One could use printf or snprintf together with MSG and ... variadic macros arguments which can be used as printf(MSG, __VA_ARGS__); maybe in combination with __VA_OPT__.