| ceed_vector.py (7f1dc7b91d4f5ca67db10df8f4f0b60afe166f53) | ceed_vector.py (962dc42db4aaccb5017a51a7cc47f13cc4a674c9) |
|---|---|
| 1# Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at 2# the Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights 3# reserved. See files LICENSE and NOTICE for details. 4# 5# This file is part of CEED, a collection of benchmarks, miniapps, software 6# libraries and APIs for efficient high-order finite element and spectral 7# element discretizations for exascale applications. For more information and 8# source code availability see http://github.com/ceed. 9# 10# The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, 11# a collaborative effort of two U.S. Department of Energy organizations (Office 12# of Science and the National Nuclear Security Administration) responsible for 13# the planning and preparation of a capable exascale ecosystem, including 14# software, applications, hardware, advanced system engineering and early 15# testbed platforms, in support of the nation's exascale computing imperative. 16 17from _ceed_cffi import ffi, lib 18import tempfile 19import numpy as np | 1# Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at 2# the Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights 3# reserved. See files LICENSE and NOTICE for details. 4# 5# This file is part of CEED, a collection of benchmarks, miniapps, software 6# libraries and APIs for efficient high-order finite element and spectral 7# element discretizations for exascale applications. For more information and 8# source code availability see http://github.com/ceed. 9# 10# The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, 11# a collaborative effort of two U.S. Department of Energy organizations (Office 12# of Science and the National Nuclear Security Administration) responsible for 13# the planning and preparation of a capable exascale ecosystem, including 14# software, applications, hardware, advanced system engineering and early 15# testbed platforms, in support of the nation's exascale computing imperative. 16 17from _ceed_cffi import ffi, lib 18import tempfile 19import numpy as np |
| 20import numba.cuda as nbcuda | |
| 21import contextlib 22from .ceed_constants import MEM_HOST, COPY_VALUES, NORM_2 23 24# ------------------------------------------------------------------------------ 25 26 27class Vector(): 28 """Ceed Vector: storing and manipulating vectors.""" --- 90 unchanged lines hidden (view full) --- 119 array_pointer[0], 120 ffi.sizeof("CeedScalar") * 121 length_pointer[0]) 122 # return Numpy array 123 return np.frombuffer(buff, dtype="float64") 124 else: 125 # CUDA array interface 126 # https://numba.pydata.org/numba-doc/latest/cuda/cuda_array_interface.html | 20import contextlib 21from .ceed_constants import MEM_HOST, COPY_VALUES, NORM_2 22 23# ------------------------------------------------------------------------------ 24 25 26class Vector(): 27 """Ceed Vector: storing and manipulating vectors.""" --- 90 unchanged lines hidden (view full) --- 118 array_pointer[0], 119 ffi.sizeof("CeedScalar") * 120 length_pointer[0]) 121 # return Numpy array 122 return np.frombuffer(buff, dtype="float64") 123 else: 124 # CUDA array interface 125 # https://numba.pydata.org/numba-doc/latest/cuda/cuda_array_interface.html |
| 126 import numba.cuda as nbcuda |
|
| 127 desc = { 128 'shape': (length_pointer[0]), 129 'typestr': '>f8', 130 'data': (int(ffi.cast("intptr_t", array_pointer[0])), False), 131 'version': 2 132 } 133 # return Numba array 134 return nbcuda.from_cuda_array_interface(desc) --- 27 unchanged lines hidden (view full) --- 162 length_pointer[0]) 163 # return read only Numpy array 164 ret = np.frombuffer(buff, dtype="float64") 165 ret.flags['WRITEABLE'] = False 166 return ret 167 else: 168 # CUDA array interface 169 # https://numba.pydata.org/numba-doc/latest/cuda/cuda_array_interface.html | 127 desc = { 128 'shape': (length_pointer[0]), 129 'typestr': '>f8', 130 'data': (int(ffi.cast("intptr_t", array_pointer[0])), False), 131 'version': 2 132 } 133 # return Numba array 134 return nbcuda.from_cuda_array_interface(desc) --- 27 unchanged lines hidden (view full) --- 162 length_pointer[0]) 163 # return read only Numpy array 164 ret = np.frombuffer(buff, dtype="float64") 165 ret.flags['WRITEABLE'] = False 166 return ret 167 else: 168 # CUDA array interface 169 # https://numba.pydata.org/numba-doc/latest/cuda/cuda_array_interface.html |
| 170 import numba.cuda as nbcuda |
|
| 170 desc = { 171 'shape': (length_pointer[0]), 172 'typestr': '>f8', 173 'data': (int(ffi.cast("intptr_t", array_pointer[0])), False), 174 'version': 2 175 } 176 # return read only Numba array 177 return nbcuda.from_cuda_array_interface(desc) --- 148 unchanged lines hidden --- | 171 desc = { 172 'shape': (length_pointer[0]), 173 'typestr': '>f8', 174 'data': (int(ffi.cast("intptr_t", array_pointer[0])), False), 175 'version': 2 176 } 177 # return read only Numba array 178 return nbcuda.from_cuda_array_interface(desc) --- 148 unchanged lines hidden --- |