MCPcopy Create free account
hub / github.com/mpi4py/mpi4py / GPUArrayCuPy

Class GPUArrayCuPy

test/arrayimpl.py:356–411  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

354
355 @add_backend
356 class GPUArrayCuPy(BaseArray):
357 backend = "cupy"
358
359 TypeMap = make_typemap([])
360 if cupy_version >= (11, 6):
361 TypeMap.update(TypeMapBool)
362 TypeMap.update(TypeMapInteger)
363 TypeMap.update(TypeMapUnsigned)
364 TypeMap.update(TypeMapFloat)
365 TypeMap.update(TypeMapComplex)
366 try:
367 cupy.array(0, "g")
368 except ValueError:
369 TypeMap.pop("g", None)
370 try:
371 cupy.array(0, "G")
372 except ValueError:
373 TypeMap.pop("G", None)
374
375 def __init__(self, arg, typecode, shape=None, readonly=False):
376 if isinstance(arg, (int, float, complex)):
377 if shape is None:
378 shape = ()
379 else:
380 if shape is None:
381 shape = len(arg)
382 self.array = cupy.zeros(shape, typecode)
383 if isinstance(arg, (int, float, complex)):
384 self.array.fill(arg)
385 else:
386 self.array[:] = cupy.asarray(arg, typecode)
387 del readonly # self.array.flags.readonly = readonly
388
389 @property
390 def address(self):
391 return self.array.__cuda_array_interface__["data"][0]
392
393 @property
394 def typecode(self):
395 return self.array.dtype.char
396
397 @property
398 def itemsize(self):
399 return self.array.itemsize
400
401 @property
402 def flat(self):
403 return self.array.ravel()
404
405 @property
406 def size(self):
407 return self.array.size
408
409 def as_raw(self):
410 cupy.cuda.get_current_stream().synchronize()
411 return self.array
412
413

Callers

nothing calls this directly

Calls 4

make_typemapFunction · 0.85
popMethod · 0.80
updateMethod · 0.45
arrayMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…