pykokkos icon indicating copy to clipboard operation
pykokkos copied to clipboard

ENH, DOC: Allocate a view without initializing?

Open tylerjereddy opened this issue 3 years ago • 1 comments

Not sure if this currently exists, if it does we may need to document it. If not, may be useful to have something similar to the C++ Kokkos::ViewAllocateWithoutInitializing, since it is a frequent occurrence to initialize a Kokkos view with the intention of replacing all entries instead of using those initial zeros (i.e., when testing and setting explicit values to the view right away after allocating).

i.e., a way to avoid the zeroing/initialization similar to np.empty()

import pykokkos as pk

def main():
    v = pk.View([10], int)
    print("v:", v)

if __name__ == "__main__":
    main()

Produces: v: [0 0 0 0 0 0 0 0 0 0]

While print(np.empty(10, dtype=int))

will produce a non-deterministic/uninitalized array like:

[140397481729328  94242978908512 140397472976112 140396602894832
 140397471432432 140396602894896 140396614373024 140396614373120
 140396614373168 140396602895168]

tylerjereddy avatar Jul 11 '22 17:07 tylerjereddy

I think the way to do this is by adding a new binding to the constructor in pykokkos-base

NaderAlAwar avatar Jul 12 '22 00:07 NaderAlAwar