You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Following the recent change to occa::memory::size() the following program:
#include<occa.hpp>intmain(constint argc, constchar **argv) {
occa::device device({{"mode", "Serial"}});
size_t Nentries = 10;
occa::memory a = device.malloc<double>(Nentries);
printf("Size of a = %ld \n", a.size());
occa::memory b = a;
b.setDtype(occa::dtype::char_);
printf("Size of a = %ld \n", a.size());
return0;
}
will print
Size of a = 10
Size of a = 80
I.e., calling occa::memory::setDtype on b modifies the 'size' of a and all other memory handles that wrap the same modeMemory. This is because dtype is held in the modeMemory class, not the memory wrapper.
While this is a bit corner case-y, I think the behavior should be that memory wrappers hold the dtype, not the modeMemory so that the return values of size when performing such type-punning is more intuitive.
The text was updated successfully, but these errors were encountered:
Following the recent change to
occa::memory::size()
the following program:will print
I.e., calling
occa::memory::setDtype
onb
modifies the 'size' ofa
and all other memory handles that wrap the samemodeMemory
. This is becausedtype
is held in themodeMemory
class, not thememory
wrapper.While this is a bit corner case-y, I think the behavior should be that
memory
wrappers hold the dtype, not themodeMemory
so that the return values ofsize
when performing such type-punning is more intuitive.The text was updated successfully, but these errors were encountered: