def _allocate_memory(self): """Allocate memory in terms of numpy ndarrays.""" debug("Allocating memory for %s (%s)" % (self.name, str(self.shape))) self._data_object = CMemory(self.shape, dtype=self.dtype) if self._first_touch: first_touch(self) else: self.data.fill(0)
def __init__(self, *args, **kwargs): if not self._cached(): self.name = kwargs.get('name') self.ndim = kwargs.get('ndim') self.npoint = kwargs.get('npoint') self.shape = (self.npoint, self.ndim) self.indices = self._indices(**kwargs) self.dtype = kwargs.get('dtype', np.float32) self.data, self.internal_pointer = malloc_aligned( self.shape, dtype=self.dtype) first_touch(self)
def _allocate_memory(self): """Function to allocate memmory in terms of numpy ndarrays. Note: memmap is a subclass of ndarray. """ if self.memmap: self._data = np.memmap(filename=self.f, dtype=self.dtype, mode='w+', shape=self.shape, order='C') else: debug("Allocating memory for %s (%s)" % (self.name, str(self.shape))) self._data, self.internal_pointer = malloc_aligned( self.shape, dtype=self.dtype) first_touch(self)