From 0d98b9da318e535b8848031aa3b516e76ed495b7 Mon Sep 17 00:00:00 2001 From: ax3l Date: Thu, 2 May 2024 03:40:47 +0000 Subject: [PATCH] Update Stub Files --- .../space1d/amrex_1d_pybind/__init__.pyi | 1847 ++++++++++++++-- .../space2d/amrex_2d_pybind/__init__.pyi | 1933 +++++++++++++++-- .../space3d/amrex_3d_pybind/__init__.pyi | 1847 ++++++++++++++-- 3 files changed, 5074 insertions(+), 553 deletions(-) diff --git a/src/amrex/space1d/amrex_1d_pybind/__init__.pyi b/src/amrex/space1d/amrex_1d_pybind/__init__.pyi index cb8cf9a2..c7ba4eff 100644 --- a/src/amrex/space1d/amrex_1d_pybind/__init__.pyi +++ b/src/amrex/space1d/amrex_1d_pybind/__init__.pyi @@ -375,7 +375,7 @@ class Array4_cdouble: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -411,7 +411,7 @@ class Array4_cdouble: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -434,7 +434,40 @@ class Array4_cdouble: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -477,7 +510,7 @@ class Array4_cdouble_const: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -513,7 +546,7 @@ class Array4_cdouble_const: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -536,7 +569,40 @@ class Array4_cdouble_const: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -593,7 +659,7 @@ class Array4_cfloat: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -629,7 +695,7 @@ class Array4_cfloat: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -652,7 +718,40 @@ class Array4_cfloat: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -695,7 +794,7 @@ class Array4_cfloat_const: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -731,7 +830,7 @@ class Array4_cfloat_const: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -754,7 +853,40 @@ class Array4_cfloat_const: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -811,7 +943,7 @@ class Array4_double: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -847,7 +979,7 @@ class Array4_double: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -870,7 +1002,40 @@ class Array4_double: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -913,7 +1078,7 @@ class Array4_double_const: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -949,7 +1114,7 @@ class Array4_double_const: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -972,7 +1137,40 @@ class Array4_double_const: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -1029,7 +1227,7 @@ class Array4_float: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -1065,7 +1263,7 @@ class Array4_float: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -1088,7 +1286,40 @@ class Array4_float: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -1131,7 +1362,7 @@ class Array4_float_const: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -1167,7 +1398,7 @@ class Array4_float_const: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -1190,7 +1421,40 @@ class Array4_float_const: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -1247,7 +1511,7 @@ class Array4_int: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -1283,7 +1547,7 @@ class Array4_int: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -1306,7 +1570,40 @@ class Array4_int: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -1349,7 +1646,7 @@ class Array4_int_const: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -1385,7 +1682,7 @@ class Array4_int_const: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -1408,7 +1705,40 @@ class Array4_int_const: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -1465,7 +1795,7 @@ class Array4_long: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -1501,7 +1831,7 @@ class Array4_long: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -1524,7 +1854,40 @@ class Array4_long: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -1567,7 +1930,7 @@ class Array4_long_const: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -1603,7 +1966,7 @@ class Array4_long_const: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -1626,7 +1989,40 @@ class Array4_long_const: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -1683,7 +2079,7 @@ class Array4_longdouble: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -1719,7 +2115,7 @@ class Array4_longdouble: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -1742,7 +2138,40 @@ class Array4_longdouble: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -1785,7 +2214,7 @@ class Array4_longdouble_const: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -1821,7 +2250,7 @@ class Array4_longdouble_const: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -1844,7 +2273,40 @@ class Array4_longdouble_const: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -1901,7 +2363,7 @@ class Array4_longlong: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -1937,7 +2399,7 @@ class Array4_longlong: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -1960,7 +2422,40 @@ class Array4_longlong: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -2003,7 +2498,43 @@ class Array4_longlong_const: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + cupy.array + A cupy n-dimensional array. + + Raises + ------ + ImportError + Raises an exception if cupy is not installed + + """ + + def to_host(self) -> numpy.ndarray[numpy.int64]: ... + def to_numpy(self, copy=False, order="F"): + """ + + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -2025,21 +2556,18 @@ class Array4_longlong_const: Returns ------- - cupy.array - A cupy n-dimensional array. - - Raises - ------ - ImportError - Raises an exception if cupy is not installed + np.array + A NumPy n-dimensional array. """ - def to_host(self) -> numpy.ndarray[numpy.int64]: ... - def to_numpy(self, copy=False, order="F"): + def to_xp(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code This includes ngrow guard cells of the box. @@ -2061,8 +2589,8 @@ class Array4_longlong_const: Returns ------- - np.array - A numpy n-dimensional array. + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -2119,7 +2647,7 @@ class Array4_short: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -2155,7 +2683,7 @@ class Array4_short: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -2178,7 +2706,40 @@ class Array4_short: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -2221,7 +2782,7 @@ class Array4_short_const: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -2257,7 +2818,7 @@ class Array4_short_const: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -2280,7 +2841,40 @@ class Array4_short_const: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -2337,7 +2931,7 @@ class Array4_uint: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -2373,7 +2967,7 @@ class Array4_uint: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -2396,7 +2990,40 @@ class Array4_uint: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -2439,7 +3066,7 @@ class Array4_uint_const: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -2475,7 +3102,7 @@ class Array4_uint_const: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -2498,7 +3125,40 @@ class Array4_uint_const: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -2555,7 +3215,7 @@ class Array4_ulong: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -2591,7 +3251,7 @@ class Array4_ulong: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -2614,7 +3274,40 @@ class Array4_ulong: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -2657,7 +3350,7 @@ class Array4_ulong_const: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -2693,7 +3386,7 @@ class Array4_ulong_const: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -2716,7 +3409,40 @@ class Array4_ulong_const: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -2773,7 +3499,7 @@ class Array4_ulonglong: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -2809,7 +3535,7 @@ class Array4_ulonglong: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -2832,7 +3558,40 @@ class Array4_ulonglong: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -2875,7 +3634,7 @@ class Array4_ulonglong_const: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -2911,7 +3670,7 @@ class Array4_ulonglong_const: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -2934,7 +3693,40 @@ class Array4_ulonglong_const: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -2991,7 +3783,7 @@ class Array4_ushort: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -3027,7 +3819,40 @@ class Array4_ushort: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + np.array + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code This includes ngrow guard cells of the box. @@ -3049,8 +3874,8 @@ class Array4_ushort: Returns ------- - np.array - A numpy n-dimensional array. + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -3093,7 +3918,7 @@ class Array4_ushort_const: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -3129,7 +3954,7 @@ class Array4_ushort_const: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -3152,7 +3977,40 @@ class Array4_ushort_const: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -3194,7 +4052,7 @@ class ArrayOfStructs_2_1_arena: def to_cupy(self, copy=False): """ - Provide Cupy views into a ArrayOfStructs. + Provide CuPy views into a ArrayOfStructs. Parameters ---------- @@ -3207,7 +4065,7 @@ class ArrayOfStructs_2_1_arena: ------- namedtuple A tuple with real and int components that are each lists - of 1D numpy arrays. + of 1D NumPy arrays. Raises ------ @@ -3220,7 +4078,30 @@ class ArrayOfStructs_2_1_arena: def to_numpy(self, copy=False): """ - Provide Numpy views into a ArrayOfStructs. + Provide NumPy views into a ArrayOfStructs. + + Parameters + ---------- + self : amrex.ArrayOfStructs_* + An ArrayOfStructs class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each lists + of 1D NumPy arrays. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a ArrayOfStructs, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -3233,7 +4114,7 @@ class ArrayOfStructs_2_1_arena: ------- namedtuple A tuple with real and int components that are each lists - of 1D numpy arrays. + of 1D NumPy or CuPy arrays. """ @@ -3269,7 +4150,7 @@ class ArrayOfStructs_2_1_default: def to_cupy(self, copy=False): """ - Provide Cupy views into a ArrayOfStructs. + Provide CuPy views into a ArrayOfStructs. Parameters ---------- @@ -3282,7 +4163,7 @@ class ArrayOfStructs_2_1_default: ------- namedtuple A tuple with real and int components that are each lists - of 1D numpy arrays. + of 1D NumPy arrays. Raises ------ @@ -3295,7 +4176,30 @@ class ArrayOfStructs_2_1_default: def to_numpy(self, copy=False): """ - Provide Numpy views into a ArrayOfStructs. + Provide NumPy views into a ArrayOfStructs. + + Parameters + ---------- + self : amrex.ArrayOfStructs_* + An ArrayOfStructs class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each lists + of 1D NumPy arrays. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a ArrayOfStructs, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -3308,7 +4212,7 @@ class ArrayOfStructs_2_1_default: ------- namedtuple A tuple with real and int components that are each lists - of 1D numpy arrays. + of 1D NumPy or CuPy arrays. """ @@ -3344,7 +4248,7 @@ class ArrayOfStructs_2_1_pinned: def to_cupy(self, copy=False): """ - Provide Cupy views into a ArrayOfStructs. + Provide CuPy views into a ArrayOfStructs. Parameters ---------- @@ -3357,7 +4261,7 @@ class ArrayOfStructs_2_1_pinned: ------- namedtuple A tuple with real and int components that are each lists - of 1D numpy arrays. + of 1D NumPy arrays. Raises ------ @@ -3370,7 +4274,7 @@ class ArrayOfStructs_2_1_pinned: def to_numpy(self, copy=False): """ - Provide Numpy views into a ArrayOfStructs. + Provide NumPy views into a ArrayOfStructs. Parameters ---------- @@ -3383,7 +4287,30 @@ class ArrayOfStructs_2_1_pinned: ------- namedtuple A tuple with real and int components that are each lists - of 1D numpy arrays. + of 1D NumPy arrays. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a ArrayOfStructs, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + Parameters + ---------- + self : amrex.ArrayOfStructs_* + An ArrayOfStructs class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each lists + of 1D NumPy or CuPy arrays. """ @@ -5455,7 +6382,7 @@ class MultiFab(FabArray_FArrayBox): def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into a MultiFab. + Provide a CuPy view into a MultiFab. This includes ngrow guard cells of each box. @@ -5478,7 +6405,7 @@ class MultiFab(FabArray_FArrayBox): Returns ------- list of cupy.array - A list of cupy n-dimensional arrays, for each local block in the + A list of CuPy n-dimensional arrays, for each local block in the MultiFab. Raises @@ -5491,7 +6418,7 @@ class MultiFab(FabArray_FArrayBox): def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into a MultiFab. + Provide a NumPy view into a MultiFab. This includes ngrow guard cells of each box. @@ -5514,7 +6441,42 @@ class MultiFab(FabArray_FArrayBox): Returns ------- list of numpy.array - A list of numpy n-dimensional arrays, for each local block in the + A list of NumPy n-dimensional arrays, for each local block in the + MultiFab. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into a MultiFab, + depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of each box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.MultiFab + A MultiFab class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + list of xp.array + A list of NumPy or CuPy n-dimensional arrays, for each local block in the MultiFab. """ @@ -5556,7 +6518,7 @@ class PODVector_int_arena: def to_cupy(self, copy=False): """ - Provide a Cupy view into a PODVector (e.g., RealVector, IntVector). + Provide a CuPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -5581,7 +6543,7 @@ class PODVector_int_arena: def to_numpy(self, copy=False): """ - Provide a Numpy view into a PODVector (e.g., RealVector, IntVector). + Provide a NumPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -5593,7 +6555,30 @@ class PODVector_int_arena: Returns ------- np.array - A 1D numpy array. + A 1D NumPy array. + + """ + + def to_xp(self, copy=False): + """ + + Provide a NumPy or CuPy view into a PODVector (e.g., RealVector, IntVector), + depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + Parameters + ---------- + self : amrex.PODVector_* + A PODVector class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + xp.array + A 1D NumPy or CuPy array. """ @@ -5633,7 +6618,7 @@ class PODVector_int_pinned: def to_cupy(self, copy=False): """ - Provide a Cupy view into a PODVector (e.g., RealVector, IntVector). + Provide a CuPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -5658,7 +6643,7 @@ class PODVector_int_pinned: def to_numpy(self, copy=False): """ - Provide a Numpy view into a PODVector (e.g., RealVector, IntVector). + Provide a NumPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -5670,7 +6655,30 @@ class PODVector_int_pinned: Returns ------- np.array - A 1D numpy array. + A 1D NumPy array. + + """ + + def to_xp(self, copy=False): + """ + + Provide a NumPy or CuPy view into a PODVector (e.g., RealVector, IntVector), + depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + Parameters + ---------- + self : amrex.PODVector_* + A PODVector class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + xp.array + A 1D NumPy or CuPy array. """ @@ -5710,7 +6718,7 @@ class PODVector_int_std: def to_cupy(self, copy=False): """ - Provide a Cupy view into a PODVector (e.g., RealVector, IntVector). + Provide a CuPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -5735,7 +6743,7 @@ class PODVector_int_std: def to_numpy(self, copy=False): """ - Provide a Numpy view into a PODVector (e.g., RealVector, IntVector). + Provide a NumPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -5747,7 +6755,30 @@ class PODVector_int_std: Returns ------- np.array - A 1D numpy array. + A 1D NumPy array. + + """ + + def to_xp(self, copy=False): + """ + + Provide a NumPy or CuPy view into a PODVector (e.g., RealVector, IntVector), + depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + Parameters + ---------- + self : amrex.PODVector_* + A PODVector class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + xp.array + A 1D NumPy or CuPy array. """ @@ -5787,7 +6818,7 @@ class PODVector_real_arena: def to_cupy(self, copy=False): """ - Provide a Cupy view into a PODVector (e.g., RealVector, IntVector). + Provide a CuPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -5812,7 +6843,7 @@ class PODVector_real_arena: def to_numpy(self, copy=False): """ - Provide a Numpy view into a PODVector (e.g., RealVector, IntVector). + Provide a NumPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -5824,7 +6855,30 @@ class PODVector_real_arena: Returns ------- np.array - A 1D numpy array. + A 1D NumPy array. + + """ + + def to_xp(self, copy=False): + """ + + Provide a NumPy or CuPy view into a PODVector (e.g., RealVector, IntVector), + depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + Parameters + ---------- + self : amrex.PODVector_* + A PODVector class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + xp.array + A 1D NumPy or CuPy array. """ @@ -5864,7 +6918,7 @@ class PODVector_real_pinned: def to_cupy(self, copy=False): """ - Provide a Cupy view into a PODVector (e.g., RealVector, IntVector). + Provide a CuPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -5889,7 +6943,7 @@ class PODVector_real_pinned: def to_numpy(self, copy=False): """ - Provide a Numpy view into a PODVector (e.g., RealVector, IntVector). + Provide a NumPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -5901,7 +6955,30 @@ class PODVector_real_pinned: Returns ------- np.array - A 1D numpy array. + A 1D NumPy array. + + """ + + def to_xp(self, copy=False): + """ + + Provide a NumPy or CuPy view into a PODVector (e.g., RealVector, IntVector), + depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + Parameters + ---------- + self : amrex.PODVector_* + A PODVector class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + xp.array + A 1D NumPy or CuPy array. """ @@ -5941,7 +7018,7 @@ class PODVector_real_std: def to_cupy(self, copy=False): """ - Provide a Cupy view into a PODVector (e.g., RealVector, IntVector). + Provide a CuPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -5966,7 +7043,7 @@ class PODVector_real_std: def to_numpy(self, copy=False): """ - Provide a Numpy view into a PODVector (e.g., RealVector, IntVector). + Provide a NumPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -5978,7 +7055,30 @@ class PODVector_real_std: Returns ------- np.array - A 1D numpy array. + A 1D NumPy array. + + """ + + def to_xp(self, copy=False): + """ + + Provide a NumPy or CuPy view into a PODVector (e.g., RealVector, IntVector), + depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + Parameters + ---------- + self : amrex.PODVector_* + A PODVector class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + xp.array + A 1D NumPy or CuPy array. """ @@ -6018,7 +7118,7 @@ class PODVector_uint64_arena: def to_cupy(self, copy=False): """ - Provide a Cupy view into a PODVector (e.g., RealVector, IntVector). + Provide a CuPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -6043,7 +7143,7 @@ class PODVector_uint64_arena: def to_numpy(self, copy=False): """ - Provide a Numpy view into a PODVector (e.g., RealVector, IntVector). + Provide a NumPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -6055,7 +7155,30 @@ class PODVector_uint64_arena: Returns ------- np.array - A 1D numpy array. + A 1D NumPy array. + + """ + + def to_xp(self, copy=False): + """ + + Provide a NumPy or CuPy view into a PODVector (e.g., RealVector, IntVector), + depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + Parameters + ---------- + self : amrex.PODVector_* + A PODVector class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + xp.array + A 1D NumPy or CuPy array. """ @@ -6095,7 +7218,7 @@ class PODVector_uint64_pinned: def to_cupy(self, copy=False): """ - Provide a Cupy view into a PODVector (e.g., RealVector, IntVector). + Provide a CuPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -6120,7 +7243,7 @@ class PODVector_uint64_pinned: def to_numpy(self, copy=False): """ - Provide a Numpy view into a PODVector (e.g., RealVector, IntVector). + Provide a NumPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -6132,7 +7255,30 @@ class PODVector_uint64_pinned: Returns ------- np.array - A 1D numpy array. + A 1D NumPy array. + + """ + + def to_xp(self, copy=False): + """ + + Provide a NumPy or CuPy view into a PODVector (e.g., RealVector, IntVector), + depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + Parameters + ---------- + self : amrex.PODVector_* + A PODVector class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + xp.array + A 1D NumPy or CuPy array. """ @@ -6172,7 +7318,7 @@ class PODVector_uint64_std: def to_cupy(self, copy=False): """ - Provide a Cupy view into a PODVector (e.g., RealVector, IntVector). + Provide a CuPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -6193,11 +7339,34 @@ class PODVector_uint64_std: """ - def to_host(self) -> PODVector_uint64_pinned: ... - def to_numpy(self, copy=False): + def to_host(self) -> PODVector_uint64_pinned: ... + def to_numpy(self, copy=False): + """ + + Provide a NumPy view into a PODVector (e.g., RealVector, IntVector). + + Parameters + ---------- + self : amrex.PODVector_* + A PODVector class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + np.array + A 1D NumPy array. + + """ + + def to_xp(self, copy=False): """ - Provide a Numpy view into a PODVector (e.g., RealVector, IntVector). + Provide a NumPy or CuPy view into a PODVector (e.g., RealVector, IntVector), + depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -6208,8 +7377,8 @@ class PODVector_uint64_std: Returns ------- - np.array - A 1D numpy array. + xp.array + A 1D NumPy or CuPy array. """ @@ -11569,7 +12738,7 @@ class StructOfArrays_1_0_idcpu_arena: def to_cupy(self, copy=False): """ - Provide Cupy views into a StructOfArrays. + Provide CuPy views into a StructOfArrays. Parameters ---------- @@ -11582,7 +12751,7 @@ class StructOfArrays_1_0_idcpu_arena: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -11597,7 +12766,33 @@ class StructOfArrays_1_0_idcpu_arena: def to_numpy(self, copy=False): """ - Provide Numpy views into a StructOfArrays. + Provide NumPy views into a StructOfArrays. + + Parameters + ---------- + self : amrex.StructOfArrays_* + A StructOfArrays class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each dicts + of 1D NumPy arrays. The dictionary key order is the same as + in the C++ component order. + For pure SoA particle layouts, an additional component idcpu + with global particle indices is populated. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a StructOfArrays, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -11610,7 +12805,7 @@ class StructOfArrays_1_0_idcpu_arena: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy or CuPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -11744,7 +12939,7 @@ class StructOfArrays_1_0_idcpu_default: def to_cupy(self, copy=False): """ - Provide Cupy views into a StructOfArrays. + Provide CuPy views into a StructOfArrays. Parameters ---------- @@ -11757,7 +12952,7 @@ class StructOfArrays_1_0_idcpu_default: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -11772,7 +12967,33 @@ class StructOfArrays_1_0_idcpu_default: def to_numpy(self, copy=False): """ - Provide Numpy views into a StructOfArrays. + Provide NumPy views into a StructOfArrays. + + Parameters + ---------- + self : amrex.StructOfArrays_* + A StructOfArrays class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each dicts + of 1D NumPy arrays. The dictionary key order is the same as + in the C++ component order. + For pure SoA particle layouts, an additional component idcpu + with global particle indices is populated. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a StructOfArrays, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -11785,7 +13006,7 @@ class StructOfArrays_1_0_idcpu_default: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy or CuPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -11919,7 +13140,7 @@ class StructOfArrays_1_0_idcpu_pinned: def to_cupy(self, copy=False): """ - Provide Cupy views into a StructOfArrays. + Provide CuPy views into a StructOfArrays. Parameters ---------- @@ -11932,7 +13153,7 @@ class StructOfArrays_1_0_idcpu_pinned: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -11947,7 +13168,33 @@ class StructOfArrays_1_0_idcpu_pinned: def to_numpy(self, copy=False): """ - Provide Numpy views into a StructOfArrays. + Provide NumPy views into a StructOfArrays. + + Parameters + ---------- + self : amrex.StructOfArrays_* + A StructOfArrays class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each dicts + of 1D NumPy arrays. The dictionary key order is the same as + in the C++ component order. + For pure SoA particle layouts, an additional component idcpu + with global particle indices is populated. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a StructOfArrays, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -11960,7 +13207,7 @@ class StructOfArrays_1_0_idcpu_pinned: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy or CuPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -12089,7 +13336,7 @@ class StructOfArrays_3_1_arena: def to_cupy(self, copy=False): """ - Provide Cupy views into a StructOfArrays. + Provide CuPy views into a StructOfArrays. Parameters ---------- @@ -12102,7 +13349,7 @@ class StructOfArrays_3_1_arena: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -12117,7 +13364,33 @@ class StructOfArrays_3_1_arena: def to_numpy(self, copy=False): """ - Provide Numpy views into a StructOfArrays. + Provide NumPy views into a StructOfArrays. + + Parameters + ---------- + self : amrex.StructOfArrays_* + A StructOfArrays class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each dicts + of 1D NumPy arrays. The dictionary key order is the same as + in the C++ component order. + For pure SoA particle layouts, an additional component idcpu + with global particle indices is populated. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a StructOfArrays, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -12130,7 +13403,7 @@ class StructOfArrays_3_1_arena: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy or CuPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -12259,7 +13532,7 @@ class StructOfArrays_3_1_default: def to_cupy(self, copy=False): """ - Provide Cupy views into a StructOfArrays. + Provide CuPy views into a StructOfArrays. Parameters ---------- @@ -12272,7 +13545,7 @@ class StructOfArrays_3_1_default: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -12287,7 +13560,33 @@ class StructOfArrays_3_1_default: def to_numpy(self, copy=False): """ - Provide Numpy views into a StructOfArrays. + Provide NumPy views into a StructOfArrays. + + Parameters + ---------- + self : amrex.StructOfArrays_* + A StructOfArrays class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each dicts + of 1D NumPy arrays. The dictionary key order is the same as + in the C++ component order. + For pure SoA particle layouts, an additional component idcpu + with global particle indices is populated. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a StructOfArrays, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -12300,7 +13599,7 @@ class StructOfArrays_3_1_default: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy or CuPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -12429,7 +13728,7 @@ class StructOfArrays_3_1_pinned: def to_cupy(self, copy=False): """ - Provide Cupy views into a StructOfArrays. + Provide CuPy views into a StructOfArrays. Parameters ---------- @@ -12442,7 +13741,7 @@ class StructOfArrays_3_1_pinned: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -12457,7 +13756,33 @@ class StructOfArrays_3_1_pinned: def to_numpy(self, copy=False): """ - Provide Numpy views into a StructOfArrays. + Provide NumPy views into a StructOfArrays. + + Parameters + ---------- + self : amrex.StructOfArrays_* + A StructOfArrays class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each dicts + of 1D NumPy arrays. The dictionary key order is the same as + in the C++ component order. + For pure SoA particle layouts, an additional component idcpu + with global particle indices is populated. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a StructOfArrays, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -12470,7 +13795,7 @@ class StructOfArrays_3_1_pinned: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy or CuPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -12604,7 +13929,7 @@ class StructOfArrays_5_0_idcpu_arena: def to_cupy(self, copy=False): """ - Provide Cupy views into a StructOfArrays. + Provide CuPy views into a StructOfArrays. Parameters ---------- @@ -12617,7 +13942,7 @@ class StructOfArrays_5_0_idcpu_arena: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -12632,7 +13957,33 @@ class StructOfArrays_5_0_idcpu_arena: def to_numpy(self, copy=False): """ - Provide Numpy views into a StructOfArrays. + Provide NumPy views into a StructOfArrays. + + Parameters + ---------- + self : amrex.StructOfArrays_* + A StructOfArrays class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each dicts + of 1D NumPy arrays. The dictionary key order is the same as + in the C++ component order. + For pure SoA particle layouts, an additional component idcpu + with global particle indices is populated. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a StructOfArrays, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -12645,7 +13996,7 @@ class StructOfArrays_5_0_idcpu_arena: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy or CuPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -12779,7 +14130,7 @@ class StructOfArrays_5_0_idcpu_default: def to_cupy(self, copy=False): """ - Provide Cupy views into a StructOfArrays. + Provide CuPy views into a StructOfArrays. Parameters ---------- @@ -12792,7 +14143,7 @@ class StructOfArrays_5_0_idcpu_default: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -12807,7 +14158,33 @@ class StructOfArrays_5_0_idcpu_default: def to_numpy(self, copy=False): """ - Provide Numpy views into a StructOfArrays. + Provide NumPy views into a StructOfArrays. + + Parameters + ---------- + self : amrex.StructOfArrays_* + A StructOfArrays class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each dicts + of 1D NumPy arrays. The dictionary key order is the same as + in the C++ component order. + For pure SoA particle layouts, an additional component idcpu + with global particle indices is populated. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a StructOfArrays, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -12820,7 +14197,7 @@ class StructOfArrays_5_0_idcpu_default: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy or CuPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -12954,7 +14331,7 @@ class StructOfArrays_5_0_idcpu_pinned: def to_cupy(self, copy=False): """ - Provide Cupy views into a StructOfArrays. + Provide CuPy views into a StructOfArrays. Parameters ---------- @@ -12967,7 +14344,7 @@ class StructOfArrays_5_0_idcpu_pinned: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -12982,7 +14359,33 @@ class StructOfArrays_5_0_idcpu_pinned: def to_numpy(self, copy=False): """ - Provide Numpy views into a StructOfArrays. + Provide NumPy views into a StructOfArrays. + + Parameters + ---------- + self : amrex.StructOfArrays_* + A StructOfArrays class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each dicts + of 1D NumPy arrays. The dictionary key order is the same as + in the C++ component order. + For pure SoA particle layouts, an additional component idcpu + with global particle indices is populated. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a StructOfArrays, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -12995,7 +14398,7 @@ class StructOfArrays_5_0_idcpu_pinned: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy or CuPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -13129,7 +14532,7 @@ class StructOfArrays_8_0_idcpu_arena: def to_cupy(self, copy=False): """ - Provide Cupy views into a StructOfArrays. + Provide CuPy views into a StructOfArrays. Parameters ---------- @@ -13142,7 +14545,7 @@ class StructOfArrays_8_0_idcpu_arena: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -13157,7 +14560,33 @@ class StructOfArrays_8_0_idcpu_arena: def to_numpy(self, copy=False): """ - Provide Numpy views into a StructOfArrays. + Provide NumPy views into a StructOfArrays. + + Parameters + ---------- + self : amrex.StructOfArrays_* + A StructOfArrays class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each dicts + of 1D NumPy arrays. The dictionary key order is the same as + in the C++ component order. + For pure SoA particle layouts, an additional component idcpu + with global particle indices is populated. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a StructOfArrays, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -13170,7 +14599,7 @@ class StructOfArrays_8_0_idcpu_arena: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy or CuPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -13304,7 +14733,7 @@ class StructOfArrays_8_0_idcpu_default: def to_cupy(self, copy=False): """ - Provide Cupy views into a StructOfArrays. + Provide CuPy views into a StructOfArrays. Parameters ---------- @@ -13317,7 +14746,7 @@ class StructOfArrays_8_0_idcpu_default: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -13332,7 +14761,33 @@ class StructOfArrays_8_0_idcpu_default: def to_numpy(self, copy=False): """ - Provide Numpy views into a StructOfArrays. + Provide NumPy views into a StructOfArrays. + + Parameters + ---------- + self : amrex.StructOfArrays_* + A StructOfArrays class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each dicts + of 1D NumPy arrays. The dictionary key order is the same as + in the C++ component order. + For pure SoA particle layouts, an additional component idcpu + with global particle indices is populated. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a StructOfArrays, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -13345,7 +14800,7 @@ class StructOfArrays_8_0_idcpu_default: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy or CuPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -13479,7 +14934,7 @@ class StructOfArrays_8_0_idcpu_pinned: def to_cupy(self, copy=False): """ - Provide Cupy views into a StructOfArrays. + Provide CuPy views into a StructOfArrays. Parameters ---------- @@ -13492,7 +14947,7 @@ class StructOfArrays_8_0_idcpu_pinned: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -13507,7 +14962,33 @@ class StructOfArrays_8_0_idcpu_pinned: def to_numpy(self, copy=False): """ - Provide Numpy views into a StructOfArrays. + Provide NumPy views into a StructOfArrays. + + Parameters + ---------- + self : amrex.StructOfArrays_* + A StructOfArrays class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each dicts + of 1D NumPy arrays. The dictionary key order is the same as + in the C++ component order. + For pure SoA particle layouts, an additional component idcpu + with global particle indices is populated. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a StructOfArrays, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -13520,7 +15001,7 @@ class StructOfArrays_8_0_idcpu_pinned: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy or CuPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. diff --git a/src/amrex/space2d/amrex_2d_pybind/__init__.pyi b/src/amrex/space2d/amrex_2d_pybind/__init__.pyi index a191c3c1..aef5f890 100644 --- a/src/amrex/space2d/amrex_2d_pybind/__init__.pyi +++ b/src/amrex/space2d/amrex_2d_pybind/__init__.pyi @@ -399,7 +399,7 @@ class Array4_cdouble: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -435,7 +435,7 @@ class Array4_cdouble: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -458,7 +458,40 @@ class Array4_cdouble: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -501,7 +534,7 @@ class Array4_cdouble_const: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -537,7 +570,7 @@ class Array4_cdouble_const: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -560,7 +593,40 @@ class Array4_cdouble_const: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -617,7 +683,7 @@ class Array4_cfloat: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -653,7 +719,7 @@ class Array4_cfloat: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -676,7 +742,40 @@ class Array4_cfloat: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -719,7 +818,7 @@ class Array4_cfloat_const: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -755,7 +854,7 @@ class Array4_cfloat_const: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -778,7 +877,40 @@ class Array4_cfloat_const: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -835,7 +967,7 @@ class Array4_double: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -871,7 +1003,7 @@ class Array4_double: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -894,7 +1026,40 @@ class Array4_double: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -937,7 +1102,7 @@ class Array4_double_const: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -973,7 +1138,7 @@ class Array4_double_const: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -996,7 +1161,40 @@ class Array4_double_const: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -1053,7 +1251,7 @@ class Array4_float: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -1089,7 +1287,7 @@ class Array4_float: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -1112,7 +1310,40 @@ class Array4_float: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -1155,7 +1386,7 @@ class Array4_float_const: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -1191,7 +1422,7 @@ class Array4_float_const: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -1214,7 +1445,40 @@ class Array4_float_const: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -1271,7 +1535,7 @@ class Array4_int: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -1307,7 +1571,7 @@ class Array4_int: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -1330,7 +1594,40 @@ class Array4_int: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -1373,7 +1670,7 @@ class Array4_int_const: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -1409,7 +1706,7 @@ class Array4_int_const: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -1432,7 +1729,40 @@ class Array4_int_const: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -1489,7 +1819,7 @@ class Array4_long: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -1525,7 +1855,7 @@ class Array4_long: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -1548,7 +1878,40 @@ class Array4_long: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -1591,7 +1954,7 @@ class Array4_long_const: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -1627,7 +1990,7 @@ class Array4_long_const: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -1650,7 +2013,40 @@ class Array4_long_const: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -1707,7 +2103,7 @@ class Array4_longdouble: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -1743,7 +2139,7 @@ class Array4_longdouble: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -1766,7 +2162,40 @@ class Array4_longdouble: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -1809,7 +2238,7 @@ class Array4_longdouble_const: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -1845,7 +2274,7 @@ class Array4_longdouble_const: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -1868,7 +2297,40 @@ class Array4_longdouble_const: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -1925,7 +2387,7 @@ class Array4_longlong: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -1961,7 +2423,7 @@ class Array4_longlong: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -1984,7 +2446,40 @@ class Array4_longlong: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -2027,7 +2522,7 @@ class Array4_longlong_const: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -2063,7 +2558,7 @@ class Array4_longlong_const: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -2086,7 +2581,40 @@ class Array4_longlong_const: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -2143,7 +2671,7 @@ class Array4_short: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -2179,7 +2707,7 @@ class Array4_short: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -2202,7 +2730,40 @@ class Array4_short: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -2245,7 +2806,7 @@ class Array4_short_const: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -2277,11 +2838,44 @@ class Array4_short_const: """ - def to_host(self) -> numpy.ndarray[numpy.int16]: ... - def to_numpy(self, copy=False, order="F"): + def to_host(self) -> numpy.ndarray[numpy.int16]: ... + def to_numpy(self, copy=False, order="F"): + """ + + Provide a NumPy view into an Array4. + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + np.array + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code This includes ngrow guard cells of the box. @@ -2303,8 +2897,8 @@ class Array4_short_const: Returns ------- - np.array - A numpy n-dimensional array. + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -2361,7 +2955,7 @@ class Array4_uint: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -2397,7 +2991,7 @@ class Array4_uint: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -2420,7 +3014,40 @@ class Array4_uint: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -2463,7 +3090,7 @@ class Array4_uint_const: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -2499,7 +3126,7 @@ class Array4_uint_const: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -2522,7 +3149,40 @@ class Array4_uint_const: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -2579,7 +3239,7 @@ class Array4_ulong: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -2615,7 +3275,7 @@ class Array4_ulong: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -2638,7 +3298,40 @@ class Array4_ulong: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -2681,7 +3374,7 @@ class Array4_ulong_const: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -2717,7 +3410,7 @@ class Array4_ulong_const: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -2740,7 +3433,40 @@ class Array4_ulong_const: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -2797,7 +3523,7 @@ class Array4_ulonglong: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -2833,7 +3559,7 @@ class Array4_ulonglong: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -2856,7 +3582,40 @@ class Array4_ulonglong: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -2899,7 +3658,7 @@ class Array4_ulonglong_const: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -2935,7 +3694,7 @@ class Array4_ulonglong_const: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -2958,7 +3717,40 @@ class Array4_ulonglong_const: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -3015,7 +3807,7 @@ class Array4_ushort: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -3051,7 +3843,7 @@ class Array4_ushort: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -3074,7 +3866,40 @@ class Array4_ushort: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -3117,7 +3942,7 @@ class Array4_ushort_const: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -3153,7 +3978,7 @@ class Array4_ushort_const: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -3176,7 +4001,40 @@ class Array4_ushort_const: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -3218,7 +4076,7 @@ class ArrayOfStructs_2_1_arena: def to_cupy(self, copy=False): """ - Provide Cupy views into a ArrayOfStructs. + Provide CuPy views into a ArrayOfStructs. Parameters ---------- @@ -3231,7 +4089,7 @@ class ArrayOfStructs_2_1_arena: ------- namedtuple A tuple with real and int components that are each lists - of 1D numpy arrays. + of 1D NumPy arrays. Raises ------ @@ -3244,7 +4102,30 @@ class ArrayOfStructs_2_1_arena: def to_numpy(self, copy=False): """ - Provide Numpy views into a ArrayOfStructs. + Provide NumPy views into a ArrayOfStructs. + + Parameters + ---------- + self : amrex.ArrayOfStructs_* + An ArrayOfStructs class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each lists + of 1D NumPy arrays. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a ArrayOfStructs, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -3257,7 +4138,7 @@ class ArrayOfStructs_2_1_arena: ------- namedtuple A tuple with real and int components that are each lists - of 1D numpy arrays. + of 1D NumPy or CuPy arrays. """ @@ -3293,7 +4174,7 @@ class ArrayOfStructs_2_1_default: def to_cupy(self, copy=False): """ - Provide Cupy views into a ArrayOfStructs. + Provide CuPy views into a ArrayOfStructs. Parameters ---------- @@ -3306,7 +4187,7 @@ class ArrayOfStructs_2_1_default: ------- namedtuple A tuple with real and int components that are each lists - of 1D numpy arrays. + of 1D NumPy arrays. Raises ------ @@ -3315,11 +4196,34 @@ class ArrayOfStructs_2_1_default: """ - def to_host(self) -> ArrayOfStructs_2_1_pinned: ... - def to_numpy(self, copy=False): + def to_host(self) -> ArrayOfStructs_2_1_pinned: ... + def to_numpy(self, copy=False): + """ + + Provide NumPy views into a ArrayOfStructs. + + Parameters + ---------- + self : amrex.ArrayOfStructs_* + An ArrayOfStructs class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each lists + of 1D NumPy arrays. + + """ + + def to_xp(self, copy=False): """ - Provide Numpy views into a ArrayOfStructs. + Provide NumPy or CuPy views into a ArrayOfStructs, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -3332,7 +4236,7 @@ class ArrayOfStructs_2_1_default: ------- namedtuple A tuple with real and int components that are each lists - of 1D numpy arrays. + of 1D NumPy or CuPy arrays. """ @@ -3368,7 +4272,7 @@ class ArrayOfStructs_2_1_pinned: def to_cupy(self, copy=False): """ - Provide Cupy views into a ArrayOfStructs. + Provide CuPy views into a ArrayOfStructs. Parameters ---------- @@ -3381,7 +4285,7 @@ class ArrayOfStructs_2_1_pinned: ------- namedtuple A tuple with real and int components that are each lists - of 1D numpy arrays. + of 1D NumPy arrays. Raises ------ @@ -3394,7 +4298,30 @@ class ArrayOfStructs_2_1_pinned: def to_numpy(self, copy=False): """ - Provide Numpy views into a ArrayOfStructs. + Provide NumPy views into a ArrayOfStructs. + + Parameters + ---------- + self : amrex.ArrayOfStructs_* + An ArrayOfStructs class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each lists + of 1D NumPy arrays. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a ArrayOfStructs, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -3407,7 +4334,7 @@ class ArrayOfStructs_2_1_pinned: ------- namedtuple A tuple with real and int components that are each lists - of 1D numpy arrays. + of 1D NumPy or CuPy arrays. """ @@ -5485,7 +6412,7 @@ class MultiFab(FabArray_FArrayBox): def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into a MultiFab. + Provide a CuPy view into a MultiFab. This includes ngrow guard cells of each box. @@ -5508,7 +6435,7 @@ class MultiFab(FabArray_FArrayBox): Returns ------- list of cupy.array - A list of cupy n-dimensional arrays, for each local block in the + A list of CuPy n-dimensional arrays, for each local block in the MultiFab. Raises @@ -5521,7 +6448,7 @@ class MultiFab(FabArray_FArrayBox): def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into a MultiFab. + Provide a NumPy view into a MultiFab. This includes ngrow guard cells of each box. @@ -5544,7 +6471,42 @@ class MultiFab(FabArray_FArrayBox): Returns ------- list of numpy.array - A list of numpy n-dimensional arrays, for each local block in the + A list of NumPy n-dimensional arrays, for each local block in the + MultiFab. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into a MultiFab, + depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of each box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.MultiFab + A MultiFab class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + list of xp.array + A list of NumPy or CuPy n-dimensional arrays, for each local block in the MultiFab. """ @@ -5586,7 +6548,7 @@ class PODVector_int_arena: def to_cupy(self, copy=False): """ - Provide a Cupy view into a PODVector (e.g., RealVector, IntVector). + Provide a CuPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -5611,7 +6573,7 @@ class PODVector_int_arena: def to_numpy(self, copy=False): """ - Provide a Numpy view into a PODVector (e.g., RealVector, IntVector). + Provide a NumPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -5623,7 +6585,30 @@ class PODVector_int_arena: Returns ------- np.array - A 1D numpy array. + A 1D NumPy array. + + """ + + def to_xp(self, copy=False): + """ + + Provide a NumPy or CuPy view into a PODVector (e.g., RealVector, IntVector), + depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + Parameters + ---------- + self : amrex.PODVector_* + A PODVector class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + xp.array + A 1D NumPy or CuPy array. """ @@ -5663,7 +6648,7 @@ class PODVector_int_pinned: def to_cupy(self, copy=False): """ - Provide a Cupy view into a PODVector (e.g., RealVector, IntVector). + Provide a CuPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -5688,7 +6673,7 @@ class PODVector_int_pinned: def to_numpy(self, copy=False): """ - Provide a Numpy view into a PODVector (e.g., RealVector, IntVector). + Provide a NumPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -5700,7 +6685,30 @@ class PODVector_int_pinned: Returns ------- np.array - A 1D numpy array. + A 1D NumPy array. + + """ + + def to_xp(self, copy=False): + """ + + Provide a NumPy or CuPy view into a PODVector (e.g., RealVector, IntVector), + depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + Parameters + ---------- + self : amrex.PODVector_* + A PODVector class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + xp.array + A 1D NumPy or CuPy array. """ @@ -5740,7 +6748,7 @@ class PODVector_int_std: def to_cupy(self, copy=False): """ - Provide a Cupy view into a PODVector (e.g., RealVector, IntVector). + Provide a CuPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -5765,7 +6773,7 @@ class PODVector_int_std: def to_numpy(self, copy=False): """ - Provide a Numpy view into a PODVector (e.g., RealVector, IntVector). + Provide a NumPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -5777,7 +6785,30 @@ class PODVector_int_std: Returns ------- np.array - A 1D numpy array. + A 1D NumPy array. + + """ + + def to_xp(self, copy=False): + """ + + Provide a NumPy or CuPy view into a PODVector (e.g., RealVector, IntVector), + depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + Parameters + ---------- + self : amrex.PODVector_* + A PODVector class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + xp.array + A 1D NumPy or CuPy array. """ @@ -5817,7 +6848,7 @@ class PODVector_real_arena: def to_cupy(self, copy=False): """ - Provide a Cupy view into a PODVector (e.g., RealVector, IntVector). + Provide a CuPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -5842,7 +6873,7 @@ class PODVector_real_arena: def to_numpy(self, copy=False): """ - Provide a Numpy view into a PODVector (e.g., RealVector, IntVector). + Provide a NumPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -5854,7 +6885,30 @@ class PODVector_real_arena: Returns ------- np.array - A 1D numpy array. + A 1D NumPy array. + + """ + + def to_xp(self, copy=False): + """ + + Provide a NumPy or CuPy view into a PODVector (e.g., RealVector, IntVector), + depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + Parameters + ---------- + self : amrex.PODVector_* + A PODVector class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + xp.array + A 1D NumPy or CuPy array. """ @@ -5894,7 +6948,7 @@ class PODVector_real_pinned: def to_cupy(self, copy=False): """ - Provide a Cupy view into a PODVector (e.g., RealVector, IntVector). + Provide a CuPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -5919,7 +6973,7 @@ class PODVector_real_pinned: def to_numpy(self, copy=False): """ - Provide a Numpy view into a PODVector (e.g., RealVector, IntVector). + Provide a NumPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -5931,7 +6985,30 @@ class PODVector_real_pinned: Returns ------- np.array - A 1D numpy array. + A 1D NumPy array. + + """ + + def to_xp(self, copy=False): + """ + + Provide a NumPy or CuPy view into a PODVector (e.g., RealVector, IntVector), + depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + Parameters + ---------- + self : amrex.PODVector_* + A PODVector class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + xp.array + A 1D NumPy or CuPy array. """ @@ -5971,7 +7048,7 @@ class PODVector_real_std: def to_cupy(self, copy=False): """ - Provide a Cupy view into a PODVector (e.g., RealVector, IntVector). + Provide a CuPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -5996,7 +7073,7 @@ class PODVector_real_std: def to_numpy(self, copy=False): """ - Provide a Numpy view into a PODVector (e.g., RealVector, IntVector). + Provide a NumPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -6008,7 +7085,30 @@ class PODVector_real_std: Returns ------- np.array - A 1D numpy array. + A 1D NumPy array. + + """ + + def to_xp(self, copy=False): + """ + + Provide a NumPy or CuPy view into a PODVector (e.g., RealVector, IntVector), + depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + Parameters + ---------- + self : amrex.PODVector_* + A PODVector class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + xp.array + A 1D NumPy or CuPy array. """ @@ -6048,7 +7148,7 @@ class PODVector_uint64_arena: def to_cupy(self, copy=False): """ - Provide a Cupy view into a PODVector (e.g., RealVector, IntVector). + Provide a CuPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -6073,7 +7173,7 @@ class PODVector_uint64_arena: def to_numpy(self, copy=False): """ - Provide a Numpy view into a PODVector (e.g., RealVector, IntVector). + Provide a NumPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -6085,7 +7185,30 @@ class PODVector_uint64_arena: Returns ------- np.array - A 1D numpy array. + A 1D NumPy array. + + """ + + def to_xp(self, copy=False): + """ + + Provide a NumPy or CuPy view into a PODVector (e.g., RealVector, IntVector), + depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + Parameters + ---------- + self : amrex.PODVector_* + A PODVector class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + xp.array + A 1D NumPy or CuPy array. """ @@ -6125,7 +7248,7 @@ class PODVector_uint64_pinned: def to_cupy(self, copy=False): """ - Provide a Cupy view into a PODVector (e.g., RealVector, IntVector). + Provide a CuPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -6150,7 +7273,7 @@ class PODVector_uint64_pinned: def to_numpy(self, copy=False): """ - Provide a Numpy view into a PODVector (e.g., RealVector, IntVector). + Provide a NumPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -6162,7 +7285,30 @@ class PODVector_uint64_pinned: Returns ------- np.array - A 1D numpy array. + A 1D NumPy array. + + """ + + def to_xp(self, copy=False): + """ + + Provide a NumPy or CuPy view into a PODVector (e.g., RealVector, IntVector), + depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + Parameters + ---------- + self : amrex.PODVector_* + A PODVector class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + xp.array + A 1D NumPy or CuPy array. """ @@ -6202,7 +7348,7 @@ class PODVector_uint64_std: def to_cupy(self, copy=False): """ - Provide a Cupy view into a PODVector (e.g., RealVector, IntVector). + Provide a CuPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -6227,7 +7373,7 @@ class PODVector_uint64_std: def to_numpy(self, copy=False): """ - Provide a Numpy view into a PODVector (e.g., RealVector, IntVector). + Provide a NumPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -6239,7 +7385,30 @@ class PODVector_uint64_std: Returns ------- np.array - A 1D numpy array. + A 1D NumPy array. + + """ + + def to_xp(self, copy=False): + """ + + Provide a NumPy or CuPy view into a PODVector (e.g., RealVector, IntVector), + depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + Parameters + ---------- + self : amrex.PODVector_* + A PODVector class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + xp.array + A 1D NumPy or CuPy array. """ @@ -12806,7 +13975,7 @@ class StructOfArrays_2_0_idcpu_arena: def to_cupy(self, copy=False): """ - Provide Cupy views into a StructOfArrays. + Provide CuPy views into a StructOfArrays. Parameters ---------- @@ -12819,7 +13988,7 @@ class StructOfArrays_2_0_idcpu_arena: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -12834,7 +14003,33 @@ class StructOfArrays_2_0_idcpu_arena: def to_numpy(self, copy=False): """ - Provide Numpy views into a StructOfArrays. + Provide NumPy views into a StructOfArrays. + + Parameters + ---------- + self : amrex.StructOfArrays_* + A StructOfArrays class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each dicts + of 1D NumPy arrays. The dictionary key order is the same as + in the C++ component order. + For pure SoA particle layouts, an additional component idcpu + with global particle indices is populated. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a StructOfArrays, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -12847,7 +14042,7 @@ class StructOfArrays_2_0_idcpu_arena: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy or CuPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -12981,7 +14176,7 @@ class StructOfArrays_2_0_idcpu_default: def to_cupy(self, copy=False): """ - Provide Cupy views into a StructOfArrays. + Provide CuPy views into a StructOfArrays. Parameters ---------- @@ -12994,7 +14189,7 @@ class StructOfArrays_2_0_idcpu_default: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -13009,7 +14204,33 @@ class StructOfArrays_2_0_idcpu_default: def to_numpy(self, copy=False): """ - Provide Numpy views into a StructOfArrays. + Provide NumPy views into a StructOfArrays. + + Parameters + ---------- + self : amrex.StructOfArrays_* + A StructOfArrays class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each dicts + of 1D NumPy arrays. The dictionary key order is the same as + in the C++ component order. + For pure SoA particle layouts, an additional component idcpu + with global particle indices is populated. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a StructOfArrays, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -13022,7 +14243,7 @@ class StructOfArrays_2_0_idcpu_default: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy or CuPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -13156,7 +14377,7 @@ class StructOfArrays_2_0_idcpu_pinned: def to_cupy(self, copy=False): """ - Provide Cupy views into a StructOfArrays. + Provide CuPy views into a StructOfArrays. Parameters ---------- @@ -13169,7 +14390,7 @@ class StructOfArrays_2_0_idcpu_pinned: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -13181,10 +14402,36 @@ class StructOfArrays_2_0_idcpu_pinned: """ - def to_numpy(self, copy=False): + def to_numpy(self, copy=False): + """ + + Provide NumPy views into a StructOfArrays. + + Parameters + ---------- + self : amrex.StructOfArrays_* + A StructOfArrays class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each dicts + of 1D NumPy arrays. The dictionary key order is the same as + in the C++ component order. + For pure SoA particle layouts, an additional component idcpu + with global particle indices is populated. + + """ + + def to_xp(self, copy=False): """ - Provide Numpy views into a StructOfArrays. + Provide NumPy or CuPy views into a StructOfArrays, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -13197,7 +14444,7 @@ class StructOfArrays_2_0_idcpu_pinned: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy or CuPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -13326,7 +14573,7 @@ class StructOfArrays_3_1_arena: def to_cupy(self, copy=False): """ - Provide Cupy views into a StructOfArrays. + Provide CuPy views into a StructOfArrays. Parameters ---------- @@ -13339,7 +14586,7 @@ class StructOfArrays_3_1_arena: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -13354,7 +14601,33 @@ class StructOfArrays_3_1_arena: def to_numpy(self, copy=False): """ - Provide Numpy views into a StructOfArrays. + Provide NumPy views into a StructOfArrays. + + Parameters + ---------- + self : amrex.StructOfArrays_* + A StructOfArrays class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each dicts + of 1D NumPy arrays. The dictionary key order is the same as + in the C++ component order. + For pure SoA particle layouts, an additional component idcpu + with global particle indices is populated. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a StructOfArrays, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -13367,7 +14640,7 @@ class StructOfArrays_3_1_arena: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy or CuPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -13496,7 +14769,7 @@ class StructOfArrays_3_1_default: def to_cupy(self, copy=False): """ - Provide Cupy views into a StructOfArrays. + Provide CuPy views into a StructOfArrays. Parameters ---------- @@ -13509,7 +14782,7 @@ class StructOfArrays_3_1_default: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -13524,7 +14797,33 @@ class StructOfArrays_3_1_default: def to_numpy(self, copy=False): """ - Provide Numpy views into a StructOfArrays. + Provide NumPy views into a StructOfArrays. + + Parameters + ---------- + self : amrex.StructOfArrays_* + A StructOfArrays class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each dicts + of 1D NumPy arrays. The dictionary key order is the same as + in the C++ component order. + For pure SoA particle layouts, an additional component idcpu + with global particle indices is populated. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a StructOfArrays, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -13537,7 +14836,7 @@ class StructOfArrays_3_1_default: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy or CuPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -13666,7 +14965,7 @@ class StructOfArrays_3_1_pinned: def to_cupy(self, copy=False): """ - Provide Cupy views into a StructOfArrays. + Provide CuPy views into a StructOfArrays. Parameters ---------- @@ -13679,7 +14978,7 @@ class StructOfArrays_3_1_pinned: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -13694,7 +14993,33 @@ class StructOfArrays_3_1_pinned: def to_numpy(self, copy=False): """ - Provide Numpy views into a StructOfArrays. + Provide NumPy views into a StructOfArrays. + + Parameters + ---------- + self : amrex.StructOfArrays_* + A StructOfArrays class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each dicts + of 1D NumPy arrays. The dictionary key order is the same as + in the C++ component order. + For pure SoA particle layouts, an additional component idcpu + with global particle indices is populated. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a StructOfArrays, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -13707,7 +15032,7 @@ class StructOfArrays_3_1_pinned: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy or CuPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -13841,7 +15166,7 @@ class StructOfArrays_6_0_idcpu_arena: def to_cupy(self, copy=False): """ - Provide Cupy views into a StructOfArrays. + Provide CuPy views into a StructOfArrays. Parameters ---------- @@ -13854,7 +15179,7 @@ class StructOfArrays_6_0_idcpu_arena: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -13869,7 +15194,33 @@ class StructOfArrays_6_0_idcpu_arena: def to_numpy(self, copy=False): """ - Provide Numpy views into a StructOfArrays. + Provide NumPy views into a StructOfArrays. + + Parameters + ---------- + self : amrex.StructOfArrays_* + A StructOfArrays class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each dicts + of 1D NumPy arrays. The dictionary key order is the same as + in the C++ component order. + For pure SoA particle layouts, an additional component idcpu + with global particle indices is populated. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a StructOfArrays, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -13882,7 +15233,7 @@ class StructOfArrays_6_0_idcpu_arena: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy or CuPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -14016,7 +15367,7 @@ class StructOfArrays_6_0_idcpu_default: def to_cupy(self, copy=False): """ - Provide Cupy views into a StructOfArrays. + Provide CuPy views into a StructOfArrays. Parameters ---------- @@ -14029,7 +15380,7 @@ class StructOfArrays_6_0_idcpu_default: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -14044,7 +15395,33 @@ class StructOfArrays_6_0_idcpu_default: def to_numpy(self, copy=False): """ - Provide Numpy views into a StructOfArrays. + Provide NumPy views into a StructOfArrays. + + Parameters + ---------- + self : amrex.StructOfArrays_* + A StructOfArrays class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each dicts + of 1D NumPy arrays. The dictionary key order is the same as + in the C++ component order. + For pure SoA particle layouts, an additional component idcpu + with global particle indices is populated. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a StructOfArrays, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -14057,7 +15434,7 @@ class StructOfArrays_6_0_idcpu_default: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy or CuPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -14191,7 +15568,7 @@ class StructOfArrays_6_0_idcpu_pinned: def to_cupy(self, copy=False): """ - Provide Cupy views into a StructOfArrays. + Provide CuPy views into a StructOfArrays. Parameters ---------- @@ -14204,7 +15581,7 @@ class StructOfArrays_6_0_idcpu_pinned: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -14219,7 +15596,33 @@ class StructOfArrays_6_0_idcpu_pinned: def to_numpy(self, copy=False): """ - Provide Numpy views into a StructOfArrays. + Provide NumPy views into a StructOfArrays. + + Parameters + ---------- + self : amrex.StructOfArrays_* + A StructOfArrays class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each dicts + of 1D NumPy arrays. The dictionary key order is the same as + in the C++ component order. + For pure SoA particle layouts, an additional component idcpu + with global particle indices is populated. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a StructOfArrays, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -14232,7 +15635,7 @@ class StructOfArrays_6_0_idcpu_pinned: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy or CuPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -14366,7 +15769,7 @@ class StructOfArrays_7_0_idcpu_arena: def to_cupy(self, copy=False): """ - Provide Cupy views into a StructOfArrays. + Provide CuPy views into a StructOfArrays. Parameters ---------- @@ -14379,7 +15782,7 @@ class StructOfArrays_7_0_idcpu_arena: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -14394,7 +15797,33 @@ class StructOfArrays_7_0_idcpu_arena: def to_numpy(self, copy=False): """ - Provide Numpy views into a StructOfArrays. + Provide NumPy views into a StructOfArrays. + + Parameters + ---------- + self : amrex.StructOfArrays_* + A StructOfArrays class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each dicts + of 1D NumPy arrays. The dictionary key order is the same as + in the C++ component order. + For pure SoA particle layouts, an additional component idcpu + with global particle indices is populated. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a StructOfArrays, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -14407,7 +15836,7 @@ class StructOfArrays_7_0_idcpu_arena: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy or CuPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -14541,7 +15970,7 @@ class StructOfArrays_7_0_idcpu_default: def to_cupy(self, copy=False): """ - Provide Cupy views into a StructOfArrays. + Provide CuPy views into a StructOfArrays. Parameters ---------- @@ -14554,7 +15983,7 @@ class StructOfArrays_7_0_idcpu_default: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -14569,7 +15998,33 @@ class StructOfArrays_7_0_idcpu_default: def to_numpy(self, copy=False): """ - Provide Numpy views into a StructOfArrays. + Provide NumPy views into a StructOfArrays. + + Parameters + ---------- + self : amrex.StructOfArrays_* + A StructOfArrays class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each dicts + of 1D NumPy arrays. The dictionary key order is the same as + in the C++ component order. + For pure SoA particle layouts, an additional component idcpu + with global particle indices is populated. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a StructOfArrays, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -14582,7 +16037,7 @@ class StructOfArrays_7_0_idcpu_default: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy or CuPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -14716,7 +16171,7 @@ class StructOfArrays_7_0_idcpu_pinned: def to_cupy(self, copy=False): """ - Provide Cupy views into a StructOfArrays. + Provide CuPy views into a StructOfArrays. Parameters ---------- @@ -14729,7 +16184,7 @@ class StructOfArrays_7_0_idcpu_pinned: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -14744,7 +16199,33 @@ class StructOfArrays_7_0_idcpu_pinned: def to_numpy(self, copy=False): """ - Provide Numpy views into a StructOfArrays. + Provide NumPy views into a StructOfArrays. + + Parameters + ---------- + self : amrex.StructOfArrays_* + A StructOfArrays class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each dicts + of 1D NumPy arrays. The dictionary key order is the same as + in the C++ component order. + For pure SoA particle layouts, an additional component idcpu + with global particle indices is populated. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a StructOfArrays, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -14757,7 +16238,7 @@ class StructOfArrays_7_0_idcpu_pinned: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy or CuPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -14891,7 +16372,7 @@ class StructOfArrays_8_0_idcpu_arena: def to_cupy(self, copy=False): """ - Provide Cupy views into a StructOfArrays. + Provide CuPy views into a StructOfArrays. Parameters ---------- @@ -14904,7 +16385,7 @@ class StructOfArrays_8_0_idcpu_arena: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -14919,7 +16400,33 @@ class StructOfArrays_8_0_idcpu_arena: def to_numpy(self, copy=False): """ - Provide Numpy views into a StructOfArrays. + Provide NumPy views into a StructOfArrays. + + Parameters + ---------- + self : amrex.StructOfArrays_* + A StructOfArrays class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each dicts + of 1D NumPy arrays. The dictionary key order is the same as + in the C++ component order. + For pure SoA particle layouts, an additional component idcpu + with global particle indices is populated. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a StructOfArrays, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -14932,7 +16439,7 @@ class StructOfArrays_8_0_idcpu_arena: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy or CuPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -15066,7 +16573,7 @@ class StructOfArrays_8_0_idcpu_default: def to_cupy(self, copy=False): """ - Provide Cupy views into a StructOfArrays. + Provide CuPy views into a StructOfArrays. Parameters ---------- @@ -15079,7 +16586,7 @@ class StructOfArrays_8_0_idcpu_default: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -15094,7 +16601,33 @@ class StructOfArrays_8_0_idcpu_default: def to_numpy(self, copy=False): """ - Provide Numpy views into a StructOfArrays. + Provide NumPy views into a StructOfArrays. + + Parameters + ---------- + self : amrex.StructOfArrays_* + A StructOfArrays class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each dicts + of 1D NumPy arrays. The dictionary key order is the same as + in the C++ component order. + For pure SoA particle layouts, an additional component idcpu + with global particle indices is populated. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a StructOfArrays, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -15107,7 +16640,7 @@ class StructOfArrays_8_0_idcpu_default: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy or CuPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -15241,7 +16774,7 @@ class StructOfArrays_8_0_idcpu_pinned: def to_cupy(self, copy=False): """ - Provide Cupy views into a StructOfArrays. + Provide CuPy views into a StructOfArrays. Parameters ---------- @@ -15254,7 +16787,7 @@ class StructOfArrays_8_0_idcpu_pinned: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -15269,7 +16802,33 @@ class StructOfArrays_8_0_idcpu_pinned: def to_numpy(self, copy=False): """ - Provide Numpy views into a StructOfArrays. + Provide NumPy views into a StructOfArrays. + + Parameters + ---------- + self : amrex.StructOfArrays_* + A StructOfArrays class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each dicts + of 1D NumPy arrays. The dictionary key order is the same as + in the C++ component order. + For pure SoA particle layouts, an additional component idcpu + with global particle indices is populated. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a StructOfArrays, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -15282,7 +16841,7 @@ class StructOfArrays_8_0_idcpu_pinned: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy or CuPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. diff --git a/src/amrex/space3d/amrex_3d_pybind/__init__.pyi b/src/amrex/space3d/amrex_3d_pybind/__init__.pyi index 3105cfa4..3652c499 100644 --- a/src/amrex/space3d/amrex_3d_pybind/__init__.pyi +++ b/src/amrex/space3d/amrex_3d_pybind/__init__.pyi @@ -375,7 +375,7 @@ class Array4_cdouble: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -411,7 +411,7 @@ class Array4_cdouble: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -434,7 +434,40 @@ class Array4_cdouble: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -477,7 +510,7 @@ class Array4_cdouble_const: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -513,7 +546,7 @@ class Array4_cdouble_const: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -536,7 +569,40 @@ class Array4_cdouble_const: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -593,7 +659,7 @@ class Array4_cfloat: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -629,7 +695,7 @@ class Array4_cfloat: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -652,7 +718,40 @@ class Array4_cfloat: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -695,7 +794,7 @@ class Array4_cfloat_const: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -731,7 +830,7 @@ class Array4_cfloat_const: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -754,7 +853,40 @@ class Array4_cfloat_const: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -811,7 +943,7 @@ class Array4_double: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -847,7 +979,7 @@ class Array4_double: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -870,7 +1002,40 @@ class Array4_double: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -913,7 +1078,7 @@ class Array4_double_const: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -949,7 +1114,7 @@ class Array4_double_const: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -972,7 +1137,40 @@ class Array4_double_const: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -1029,7 +1227,7 @@ class Array4_float: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -1065,7 +1263,7 @@ class Array4_float: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -1088,7 +1286,40 @@ class Array4_float: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -1131,7 +1362,7 @@ class Array4_float_const: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -1167,7 +1398,7 @@ class Array4_float_const: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -1190,7 +1421,40 @@ class Array4_float_const: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -1247,7 +1511,7 @@ class Array4_int: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -1283,7 +1547,7 @@ class Array4_int: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -1306,7 +1570,40 @@ class Array4_int: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -1349,7 +1646,7 @@ class Array4_int_const: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -1385,7 +1682,7 @@ class Array4_int_const: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -1408,7 +1705,40 @@ class Array4_int_const: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -1465,7 +1795,7 @@ class Array4_long: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -1501,7 +1831,7 @@ class Array4_long: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -1524,7 +1854,40 @@ class Array4_long: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -1567,7 +1930,7 @@ class Array4_long_const: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -1603,7 +1966,7 @@ class Array4_long_const: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -1626,7 +1989,40 @@ class Array4_long_const: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -1683,7 +2079,7 @@ class Array4_longdouble: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -1719,7 +2115,7 @@ class Array4_longdouble: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -1742,7 +2138,40 @@ class Array4_longdouble: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -1785,7 +2214,7 @@ class Array4_longdouble_const: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -1821,7 +2250,7 @@ class Array4_longdouble_const: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -1844,7 +2273,40 @@ class Array4_longdouble_const: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -1901,7 +2363,7 @@ class Array4_longlong: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -1937,7 +2399,7 @@ class Array4_longlong: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -1960,7 +2422,40 @@ class Array4_longlong: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -2003,7 +2498,43 @@ class Array4_longlong_const: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + cupy.array + A cupy n-dimensional array. + + Raises + ------ + ImportError + Raises an exception if cupy is not installed + + """ + + def to_host(self) -> numpy.ndarray[numpy.int64]: ... + def to_numpy(self, copy=False, order="F"): + """ + + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -2025,21 +2556,18 @@ class Array4_longlong_const: Returns ------- - cupy.array - A cupy n-dimensional array. - - Raises - ------ - ImportError - Raises an exception if cupy is not installed + np.array + A NumPy n-dimensional array. """ - def to_host(self) -> numpy.ndarray[numpy.int64]: ... - def to_numpy(self, copy=False, order="F"): + def to_xp(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code This includes ngrow guard cells of the box. @@ -2061,8 +2589,8 @@ class Array4_longlong_const: Returns ------- - np.array - A numpy n-dimensional array. + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -2119,7 +2647,7 @@ class Array4_short: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -2155,7 +2683,7 @@ class Array4_short: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -2178,7 +2706,40 @@ class Array4_short: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -2221,7 +2782,7 @@ class Array4_short_const: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -2257,7 +2818,7 @@ class Array4_short_const: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -2280,7 +2841,40 @@ class Array4_short_const: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -2337,7 +2931,7 @@ class Array4_uint: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -2373,7 +2967,7 @@ class Array4_uint: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -2396,7 +2990,40 @@ class Array4_uint: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -2439,7 +3066,7 @@ class Array4_uint_const: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -2475,7 +3102,7 @@ class Array4_uint_const: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -2498,7 +3125,40 @@ class Array4_uint_const: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -2555,7 +3215,7 @@ class Array4_ulong: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -2591,7 +3251,7 @@ class Array4_ulong: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -2614,7 +3274,40 @@ class Array4_ulong: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -2657,7 +3350,7 @@ class Array4_ulong_const: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -2693,7 +3386,7 @@ class Array4_ulong_const: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -2716,7 +3409,40 @@ class Array4_ulong_const: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -2773,7 +3499,7 @@ class Array4_ulonglong: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -2809,7 +3535,7 @@ class Array4_ulonglong: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -2832,7 +3558,40 @@ class Array4_ulonglong: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -2875,7 +3634,7 @@ class Array4_ulonglong_const: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -2911,7 +3670,7 @@ class Array4_ulonglong_const: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -2934,7 +3693,40 @@ class Array4_ulonglong_const: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -2991,7 +3783,7 @@ class Array4_ushort: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -3027,7 +3819,40 @@ class Array4_ushort: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + np.array + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code This includes ngrow guard cells of the box. @@ -3049,8 +3874,8 @@ class Array4_ushort: Returns ------- - np.array - A numpy n-dimensional array. + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -3093,7 +3918,7 @@ class Array4_ushort_const: def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into an Array4. + Provide a CuPy view into an Array4. This includes ngrow guard cells of the box. @@ -3129,7 +3954,7 @@ class Array4_ushort_const: def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into an Array4. + Provide a NumPy view into an Array4. This includes ngrow guard cells of the box. @@ -3152,7 +3977,40 @@ class Array4_ushort_const: Returns ------- np.array - A numpy n-dimensional array. + A NumPy n-dimensional array. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into an Array4, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of the box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.Array4_* + An Array4 class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + xp.array + A NumPy or CuPy n-dimensional array. """ @@ -3194,7 +4052,7 @@ class ArrayOfStructs_2_1_arena: def to_cupy(self, copy=False): """ - Provide Cupy views into a ArrayOfStructs. + Provide CuPy views into a ArrayOfStructs. Parameters ---------- @@ -3207,7 +4065,7 @@ class ArrayOfStructs_2_1_arena: ------- namedtuple A tuple with real and int components that are each lists - of 1D numpy arrays. + of 1D NumPy arrays. Raises ------ @@ -3220,7 +4078,30 @@ class ArrayOfStructs_2_1_arena: def to_numpy(self, copy=False): """ - Provide Numpy views into a ArrayOfStructs. + Provide NumPy views into a ArrayOfStructs. + + Parameters + ---------- + self : amrex.ArrayOfStructs_* + An ArrayOfStructs class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each lists + of 1D NumPy arrays. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a ArrayOfStructs, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -3233,7 +4114,7 @@ class ArrayOfStructs_2_1_arena: ------- namedtuple A tuple with real and int components that are each lists - of 1D numpy arrays. + of 1D NumPy or CuPy arrays. """ @@ -3269,7 +4150,7 @@ class ArrayOfStructs_2_1_default: def to_cupy(self, copy=False): """ - Provide Cupy views into a ArrayOfStructs. + Provide CuPy views into a ArrayOfStructs. Parameters ---------- @@ -3282,7 +4163,7 @@ class ArrayOfStructs_2_1_default: ------- namedtuple A tuple with real and int components that are each lists - of 1D numpy arrays. + of 1D NumPy arrays. Raises ------ @@ -3295,7 +4176,30 @@ class ArrayOfStructs_2_1_default: def to_numpy(self, copy=False): """ - Provide Numpy views into a ArrayOfStructs. + Provide NumPy views into a ArrayOfStructs. + + Parameters + ---------- + self : amrex.ArrayOfStructs_* + An ArrayOfStructs class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each lists + of 1D NumPy arrays. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a ArrayOfStructs, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -3308,7 +4212,7 @@ class ArrayOfStructs_2_1_default: ------- namedtuple A tuple with real and int components that are each lists - of 1D numpy arrays. + of 1D NumPy or CuPy arrays. """ @@ -3344,7 +4248,7 @@ class ArrayOfStructs_2_1_pinned: def to_cupy(self, copy=False): """ - Provide Cupy views into a ArrayOfStructs. + Provide CuPy views into a ArrayOfStructs. Parameters ---------- @@ -3357,7 +4261,7 @@ class ArrayOfStructs_2_1_pinned: ------- namedtuple A tuple with real and int components that are each lists - of 1D numpy arrays. + of 1D NumPy arrays. Raises ------ @@ -3370,7 +4274,7 @@ class ArrayOfStructs_2_1_pinned: def to_numpy(self, copy=False): """ - Provide Numpy views into a ArrayOfStructs. + Provide NumPy views into a ArrayOfStructs. Parameters ---------- @@ -3383,7 +4287,30 @@ class ArrayOfStructs_2_1_pinned: ------- namedtuple A tuple with real and int components that are each lists - of 1D numpy arrays. + of 1D NumPy arrays. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a ArrayOfStructs, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + Parameters + ---------- + self : amrex.ArrayOfStructs_* + An ArrayOfStructs class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each lists + of 1D NumPy or CuPy arrays. """ @@ -5464,7 +6391,7 @@ class MultiFab(FabArray_FArrayBox): def to_cupy(self, copy=False, order="F"): """ - Provide a Cupy view into a MultiFab. + Provide a CuPy view into a MultiFab. This includes ngrow guard cells of each box. @@ -5487,7 +6414,7 @@ class MultiFab(FabArray_FArrayBox): Returns ------- list of cupy.array - A list of cupy n-dimensional arrays, for each local block in the + A list of CuPy n-dimensional arrays, for each local block in the MultiFab. Raises @@ -5500,7 +6427,7 @@ class MultiFab(FabArray_FArrayBox): def to_numpy(self, copy=False, order="F"): """ - Provide a Numpy view into a MultiFab. + Provide a NumPy view into a MultiFab. This includes ngrow guard cells of each box. @@ -5523,7 +6450,42 @@ class MultiFab(FabArray_FArrayBox): Returns ------- list of numpy.array - A list of numpy n-dimensional arrays, for each local block in the + A list of NumPy n-dimensional arrays, for each local block in the + MultiFab. + + """ + + def to_xp(self, copy=False, order="F"): + """ + + Provide a NumPy or CuPy view into a MultiFab, + depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + This includes ngrow guard cells of each box. + + Note on the order of indices: + By default, this is as in AMReX in Fortran contiguous order, indexing as + x,y,z. This has performance implications for use in external libraries such + as cupy. + The order="C" option will index as z,y,x and perform better with cupy. + https://github.com/AMReX-Codes/pyamrex/issues/55#issuecomment-1579610074 + + Parameters + ---------- + self : amrex.MultiFab + A MultiFab class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + order : string, optional + F order (default) or C. C is faster with external libraries. + + Returns + ------- + list of xp.array + A list of NumPy or CuPy n-dimensional arrays, for each local block in the MultiFab. """ @@ -5565,7 +6527,7 @@ class PODVector_int_arena: def to_cupy(self, copy=False): """ - Provide a Cupy view into a PODVector (e.g., RealVector, IntVector). + Provide a CuPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -5590,7 +6552,7 @@ class PODVector_int_arena: def to_numpy(self, copy=False): """ - Provide a Numpy view into a PODVector (e.g., RealVector, IntVector). + Provide a NumPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -5602,7 +6564,30 @@ class PODVector_int_arena: Returns ------- np.array - A 1D numpy array. + A 1D NumPy array. + + """ + + def to_xp(self, copy=False): + """ + + Provide a NumPy or CuPy view into a PODVector (e.g., RealVector, IntVector), + depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + Parameters + ---------- + self : amrex.PODVector_* + A PODVector class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + xp.array + A 1D NumPy or CuPy array. """ @@ -5642,7 +6627,7 @@ class PODVector_int_pinned: def to_cupy(self, copy=False): """ - Provide a Cupy view into a PODVector (e.g., RealVector, IntVector). + Provide a CuPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -5667,7 +6652,7 @@ class PODVector_int_pinned: def to_numpy(self, copy=False): """ - Provide a Numpy view into a PODVector (e.g., RealVector, IntVector). + Provide a NumPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -5679,7 +6664,30 @@ class PODVector_int_pinned: Returns ------- np.array - A 1D numpy array. + A 1D NumPy array. + + """ + + def to_xp(self, copy=False): + """ + + Provide a NumPy or CuPy view into a PODVector (e.g., RealVector, IntVector), + depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + Parameters + ---------- + self : amrex.PODVector_* + A PODVector class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + xp.array + A 1D NumPy or CuPy array. """ @@ -5719,7 +6727,7 @@ class PODVector_int_std: def to_cupy(self, copy=False): """ - Provide a Cupy view into a PODVector (e.g., RealVector, IntVector). + Provide a CuPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -5744,7 +6752,7 @@ class PODVector_int_std: def to_numpy(self, copy=False): """ - Provide a Numpy view into a PODVector (e.g., RealVector, IntVector). + Provide a NumPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -5756,7 +6764,30 @@ class PODVector_int_std: Returns ------- np.array - A 1D numpy array. + A 1D NumPy array. + + """ + + def to_xp(self, copy=False): + """ + + Provide a NumPy or CuPy view into a PODVector (e.g., RealVector, IntVector), + depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + Parameters + ---------- + self : amrex.PODVector_* + A PODVector class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + xp.array + A 1D NumPy or CuPy array. """ @@ -5796,7 +6827,7 @@ class PODVector_real_arena: def to_cupy(self, copy=False): """ - Provide a Cupy view into a PODVector (e.g., RealVector, IntVector). + Provide a CuPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -5821,7 +6852,7 @@ class PODVector_real_arena: def to_numpy(self, copy=False): """ - Provide a Numpy view into a PODVector (e.g., RealVector, IntVector). + Provide a NumPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -5833,7 +6864,30 @@ class PODVector_real_arena: Returns ------- np.array - A 1D numpy array. + A 1D NumPy array. + + """ + + def to_xp(self, copy=False): + """ + + Provide a NumPy or CuPy view into a PODVector (e.g., RealVector, IntVector), + depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + Parameters + ---------- + self : amrex.PODVector_* + A PODVector class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + xp.array + A 1D NumPy or CuPy array. """ @@ -5873,7 +6927,7 @@ class PODVector_real_pinned: def to_cupy(self, copy=False): """ - Provide a Cupy view into a PODVector (e.g., RealVector, IntVector). + Provide a CuPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -5898,7 +6952,7 @@ class PODVector_real_pinned: def to_numpy(self, copy=False): """ - Provide a Numpy view into a PODVector (e.g., RealVector, IntVector). + Provide a NumPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -5910,7 +6964,30 @@ class PODVector_real_pinned: Returns ------- np.array - A 1D numpy array. + A 1D NumPy array. + + """ + + def to_xp(self, copy=False): + """ + + Provide a NumPy or CuPy view into a PODVector (e.g., RealVector, IntVector), + depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + Parameters + ---------- + self : amrex.PODVector_* + A PODVector class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + xp.array + A 1D NumPy or CuPy array. """ @@ -5950,7 +7027,7 @@ class PODVector_real_std: def to_cupy(self, copy=False): """ - Provide a Cupy view into a PODVector (e.g., RealVector, IntVector). + Provide a CuPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -5975,7 +7052,7 @@ class PODVector_real_std: def to_numpy(self, copy=False): """ - Provide a Numpy view into a PODVector (e.g., RealVector, IntVector). + Provide a NumPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -5987,7 +7064,30 @@ class PODVector_real_std: Returns ------- np.array - A 1D numpy array. + A 1D NumPy array. + + """ + + def to_xp(self, copy=False): + """ + + Provide a NumPy or CuPy view into a PODVector (e.g., RealVector, IntVector), + depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + Parameters + ---------- + self : amrex.PODVector_* + A PODVector class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + xp.array + A 1D NumPy or CuPy array. """ @@ -6027,7 +7127,7 @@ class PODVector_uint64_arena: def to_cupy(self, copy=False): """ - Provide a Cupy view into a PODVector (e.g., RealVector, IntVector). + Provide a CuPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -6052,7 +7152,7 @@ class PODVector_uint64_arena: def to_numpy(self, copy=False): """ - Provide a Numpy view into a PODVector (e.g., RealVector, IntVector). + Provide a NumPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -6064,7 +7164,30 @@ class PODVector_uint64_arena: Returns ------- np.array - A 1D numpy array. + A 1D NumPy array. + + """ + + def to_xp(self, copy=False): + """ + + Provide a NumPy or CuPy view into a PODVector (e.g., RealVector, IntVector), + depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + Parameters + ---------- + self : amrex.PODVector_* + A PODVector class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + xp.array + A 1D NumPy or CuPy array. """ @@ -6104,7 +7227,7 @@ class PODVector_uint64_pinned: def to_cupy(self, copy=False): """ - Provide a Cupy view into a PODVector (e.g., RealVector, IntVector). + Provide a CuPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -6129,7 +7252,7 @@ class PODVector_uint64_pinned: def to_numpy(self, copy=False): """ - Provide a Numpy view into a PODVector (e.g., RealVector, IntVector). + Provide a NumPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -6141,7 +7264,30 @@ class PODVector_uint64_pinned: Returns ------- np.array - A 1D numpy array. + A 1D NumPy array. + + """ + + def to_xp(self, copy=False): + """ + + Provide a NumPy or CuPy view into a PODVector (e.g., RealVector, IntVector), + depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code + + Parameters + ---------- + self : amrex.PODVector_* + A PODVector class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + xp.array + A 1D NumPy or CuPy array. """ @@ -6181,7 +7327,7 @@ class PODVector_uint64_std: def to_cupy(self, copy=False): """ - Provide a Cupy view into a PODVector (e.g., RealVector, IntVector). + Provide a CuPy view into a PODVector (e.g., RealVector, IntVector). Parameters ---------- @@ -6202,11 +7348,34 @@ class PODVector_uint64_std: """ - def to_host(self) -> PODVector_uint64_pinned: ... - def to_numpy(self, copy=False): + def to_host(self) -> PODVector_uint64_pinned: ... + def to_numpy(self, copy=False): + """ + + Provide a NumPy view into a PODVector (e.g., RealVector, IntVector). + + Parameters + ---------- + self : amrex.PODVector_* + A PODVector class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + np.array + A 1D NumPy array. + + """ + + def to_xp(self, copy=False): """ - Provide a Numpy view into a PODVector (e.g., RealVector, IntVector). + Provide a NumPy or CuPy view into a PODVector (e.g., RealVector, IntVector), + depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -6217,8 +7386,8 @@ class PODVector_uint64_std: Returns ------- - np.array - A 1D numpy array. + xp.array + A 1D NumPy or CuPy array. """ @@ -11603,7 +12772,7 @@ class StructOfArrays_3_0_idcpu_arena: def to_cupy(self, copy=False): """ - Provide Cupy views into a StructOfArrays. + Provide CuPy views into a StructOfArrays. Parameters ---------- @@ -11616,7 +12785,7 @@ class StructOfArrays_3_0_idcpu_arena: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -11631,7 +12800,33 @@ class StructOfArrays_3_0_idcpu_arena: def to_numpy(self, copy=False): """ - Provide Numpy views into a StructOfArrays. + Provide NumPy views into a StructOfArrays. + + Parameters + ---------- + self : amrex.StructOfArrays_* + A StructOfArrays class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each dicts + of 1D NumPy arrays. The dictionary key order is the same as + in the C++ component order. + For pure SoA particle layouts, an additional component idcpu + with global particle indices is populated. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a StructOfArrays, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -11644,7 +12839,7 @@ class StructOfArrays_3_0_idcpu_arena: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy or CuPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -11778,7 +12973,7 @@ class StructOfArrays_3_0_idcpu_default: def to_cupy(self, copy=False): """ - Provide Cupy views into a StructOfArrays. + Provide CuPy views into a StructOfArrays. Parameters ---------- @@ -11791,7 +12986,7 @@ class StructOfArrays_3_0_idcpu_default: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -11806,7 +13001,33 @@ class StructOfArrays_3_0_idcpu_default: def to_numpy(self, copy=False): """ - Provide Numpy views into a StructOfArrays. + Provide NumPy views into a StructOfArrays. + + Parameters + ---------- + self : amrex.StructOfArrays_* + A StructOfArrays class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each dicts + of 1D NumPy arrays. The dictionary key order is the same as + in the C++ component order. + For pure SoA particle layouts, an additional component idcpu + with global particle indices is populated. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a StructOfArrays, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -11819,7 +13040,7 @@ class StructOfArrays_3_0_idcpu_default: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy or CuPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -11953,7 +13174,7 @@ class StructOfArrays_3_0_idcpu_pinned: def to_cupy(self, copy=False): """ - Provide Cupy views into a StructOfArrays. + Provide CuPy views into a StructOfArrays. Parameters ---------- @@ -11966,7 +13187,7 @@ class StructOfArrays_3_0_idcpu_pinned: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -11981,7 +13202,33 @@ class StructOfArrays_3_0_idcpu_pinned: def to_numpy(self, copy=False): """ - Provide Numpy views into a StructOfArrays. + Provide NumPy views into a StructOfArrays. + + Parameters + ---------- + self : amrex.StructOfArrays_* + A StructOfArrays class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each dicts + of 1D NumPy arrays. The dictionary key order is the same as + in the C++ component order. + For pure SoA particle layouts, an additional component idcpu + with global particle indices is populated. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a StructOfArrays, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -11994,7 +13241,7 @@ class StructOfArrays_3_0_idcpu_pinned: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy or CuPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -12123,7 +13370,7 @@ class StructOfArrays_3_1_arena: def to_cupy(self, copy=False): """ - Provide Cupy views into a StructOfArrays. + Provide CuPy views into a StructOfArrays. Parameters ---------- @@ -12136,7 +13383,7 @@ class StructOfArrays_3_1_arena: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -12151,7 +13398,33 @@ class StructOfArrays_3_1_arena: def to_numpy(self, copy=False): """ - Provide Numpy views into a StructOfArrays. + Provide NumPy views into a StructOfArrays. + + Parameters + ---------- + self : amrex.StructOfArrays_* + A StructOfArrays class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each dicts + of 1D NumPy arrays. The dictionary key order is the same as + in the C++ component order. + For pure SoA particle layouts, an additional component idcpu + with global particle indices is populated. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a StructOfArrays, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -12164,7 +13437,7 @@ class StructOfArrays_3_1_arena: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy or CuPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -12293,7 +13566,7 @@ class StructOfArrays_3_1_default: def to_cupy(self, copy=False): """ - Provide Cupy views into a StructOfArrays. + Provide CuPy views into a StructOfArrays. Parameters ---------- @@ -12306,7 +13579,7 @@ class StructOfArrays_3_1_default: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -12321,7 +13594,33 @@ class StructOfArrays_3_1_default: def to_numpy(self, copy=False): """ - Provide Numpy views into a StructOfArrays. + Provide NumPy views into a StructOfArrays. + + Parameters + ---------- + self : amrex.StructOfArrays_* + A StructOfArrays class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each dicts + of 1D NumPy arrays. The dictionary key order is the same as + in the C++ component order. + For pure SoA particle layouts, an additional component idcpu + with global particle indices is populated. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a StructOfArrays, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -12334,7 +13633,7 @@ class StructOfArrays_3_1_default: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy or CuPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -12463,7 +13762,7 @@ class StructOfArrays_3_1_pinned: def to_cupy(self, copy=False): """ - Provide Cupy views into a StructOfArrays. + Provide CuPy views into a StructOfArrays. Parameters ---------- @@ -12476,7 +13775,7 @@ class StructOfArrays_3_1_pinned: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -12491,7 +13790,33 @@ class StructOfArrays_3_1_pinned: def to_numpy(self, copy=False): """ - Provide Numpy views into a StructOfArrays. + Provide NumPy views into a StructOfArrays. + + Parameters + ---------- + self : amrex.StructOfArrays_* + A StructOfArrays class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each dicts + of 1D NumPy arrays. The dictionary key order is the same as + in the C++ component order. + For pure SoA particle layouts, an additional component idcpu + with global particle indices is populated. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a StructOfArrays, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -12504,7 +13829,7 @@ class StructOfArrays_3_1_pinned: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy or CuPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -12638,7 +13963,7 @@ class StructOfArrays_7_0_idcpu_arena: def to_cupy(self, copy=False): """ - Provide Cupy views into a StructOfArrays. + Provide CuPy views into a StructOfArrays. Parameters ---------- @@ -12651,7 +13976,7 @@ class StructOfArrays_7_0_idcpu_arena: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -12666,7 +13991,33 @@ class StructOfArrays_7_0_idcpu_arena: def to_numpy(self, copy=False): """ - Provide Numpy views into a StructOfArrays. + Provide NumPy views into a StructOfArrays. + + Parameters + ---------- + self : amrex.StructOfArrays_* + A StructOfArrays class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each dicts + of 1D NumPy arrays. The dictionary key order is the same as + in the C++ component order. + For pure SoA particle layouts, an additional component idcpu + with global particle indices is populated. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a StructOfArrays, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -12679,7 +14030,7 @@ class StructOfArrays_7_0_idcpu_arena: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy or CuPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -12813,7 +14164,7 @@ class StructOfArrays_7_0_idcpu_default: def to_cupy(self, copy=False): """ - Provide Cupy views into a StructOfArrays. + Provide CuPy views into a StructOfArrays. Parameters ---------- @@ -12826,7 +14177,7 @@ class StructOfArrays_7_0_idcpu_default: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -12841,7 +14192,33 @@ class StructOfArrays_7_0_idcpu_default: def to_numpy(self, copy=False): """ - Provide Numpy views into a StructOfArrays. + Provide NumPy views into a StructOfArrays. + + Parameters + ---------- + self : amrex.StructOfArrays_* + A StructOfArrays class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each dicts + of 1D NumPy arrays. The dictionary key order is the same as + in the C++ component order. + For pure SoA particle layouts, an additional component idcpu + with global particle indices is populated. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a StructOfArrays, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -12854,7 +14231,7 @@ class StructOfArrays_7_0_idcpu_default: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy or CuPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -12988,7 +14365,7 @@ class StructOfArrays_7_0_idcpu_pinned: def to_cupy(self, copy=False): """ - Provide Cupy views into a StructOfArrays. + Provide CuPy views into a StructOfArrays. Parameters ---------- @@ -13001,7 +14378,7 @@ class StructOfArrays_7_0_idcpu_pinned: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -13016,7 +14393,33 @@ class StructOfArrays_7_0_idcpu_pinned: def to_numpy(self, copy=False): """ - Provide Numpy views into a StructOfArrays. + Provide NumPy views into a StructOfArrays. + + Parameters + ---------- + self : amrex.StructOfArrays_* + A StructOfArrays class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each dicts + of 1D NumPy arrays. The dictionary key order is the same as + in the C++ component order. + For pure SoA particle layouts, an additional component idcpu + with global particle indices is populated. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a StructOfArrays, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -13029,7 +14432,7 @@ class StructOfArrays_7_0_idcpu_pinned: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy or CuPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -13163,7 +14566,7 @@ class StructOfArrays_8_0_idcpu_arena: def to_cupy(self, copy=False): """ - Provide Cupy views into a StructOfArrays. + Provide CuPy views into a StructOfArrays. Parameters ---------- @@ -13176,7 +14579,7 @@ class StructOfArrays_8_0_idcpu_arena: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -13191,7 +14594,33 @@ class StructOfArrays_8_0_idcpu_arena: def to_numpy(self, copy=False): """ - Provide Numpy views into a StructOfArrays. + Provide NumPy views into a StructOfArrays. + + Parameters + ---------- + self : amrex.StructOfArrays_* + A StructOfArrays class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each dicts + of 1D NumPy arrays. The dictionary key order is the same as + in the C++ component order. + For pure SoA particle layouts, an additional component idcpu + with global particle indices is populated. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a StructOfArrays, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -13204,7 +14633,7 @@ class StructOfArrays_8_0_idcpu_arena: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy or CuPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -13338,7 +14767,7 @@ class StructOfArrays_8_0_idcpu_default: def to_cupy(self, copy=False): """ - Provide Cupy views into a StructOfArrays. + Provide CuPy views into a StructOfArrays. Parameters ---------- @@ -13351,7 +14780,7 @@ class StructOfArrays_8_0_idcpu_default: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -13366,7 +14795,33 @@ class StructOfArrays_8_0_idcpu_default: def to_numpy(self, copy=False): """ - Provide Numpy views into a StructOfArrays. + Provide NumPy views into a StructOfArrays. + + Parameters + ---------- + self : amrex.StructOfArrays_* + A StructOfArrays class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each dicts + of 1D NumPy arrays. The dictionary key order is the same as + in the C++ component order. + For pure SoA particle layouts, an additional component idcpu + with global particle indices is populated. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a StructOfArrays, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -13379,7 +14834,7 @@ class StructOfArrays_8_0_idcpu_default: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy or CuPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -13513,7 +14968,7 @@ class StructOfArrays_8_0_idcpu_pinned: def to_cupy(self, copy=False): """ - Provide Cupy views into a StructOfArrays. + Provide CuPy views into a StructOfArrays. Parameters ---------- @@ -13526,7 +14981,7 @@ class StructOfArrays_8_0_idcpu_pinned: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated. @@ -13541,7 +14996,33 @@ class StructOfArrays_8_0_idcpu_pinned: def to_numpy(self, copy=False): """ - Provide Numpy views into a StructOfArrays. + Provide NumPy views into a StructOfArrays. + + Parameters + ---------- + self : amrex.StructOfArrays_* + A StructOfArrays class in pyAMReX + copy : bool, optional + Copy the data if true, otherwise create a view (default). + + Returns + ------- + namedtuple + A tuple with real and int components that are each dicts + of 1D NumPy arrays. The dictionary key order is the same as + in the C++ component order. + For pure SoA particle layouts, an additional component idcpu + with global particle indices is populated. + + """ + + def to_xp(self, copy=False): + """ + + Provide NumPy or CuPy views into a StructOfArrays, depending on amr.Config.have_gpu . + + This function is similar to CuPy's xp naming suggestion for CPU/GPU agnostic code: + https://docs.cupy.dev/en/stable/user_guide/basic.html#how-to-write-cpu-gpu-agnostic-code Parameters ---------- @@ -13554,7 +15035,7 @@ class StructOfArrays_8_0_idcpu_pinned: ------- namedtuple A tuple with real and int components that are each dicts - of 1D numpy arrays. The dictionary key order is the same as + of 1D NumPy or CuPy arrays. The dictionary key order is the same as in the C++ component order. For pure SoA particle layouts, an additional component idcpu with global particle indices is populated.