From 619480a15b582dd0f45af3e0ab1c90d06a40d591 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Wed, 1 May 2024 17:09:33 -0700 Subject: [PATCH] SoA: Fix CuPy Fix two errors in SoA runtime and `idcpu` representation in CuPy. --- src/amrex/StructOfArrays.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/amrex/StructOfArrays.py b/src/amrex/StructOfArrays.py index 7dff6128..ec779b79 100644 --- a/src/amrex/StructOfArrays.py +++ b/src/amrex/StructOfArrays.py @@ -165,7 +165,12 @@ def soa_to_cupy(self, copy=False): else: soa_view = SoA_cp({}, {}, None) - real_comp_names = self.soa_real_comps(self.num_real_comps) + # for the legacy data layout, do not start with x, y, z but with a, b, c, ... + if self.has_idcpu: + real_comp_names = self.soa_real_comps(self.num_real_comps) + else: + real_comp_names = self.soa_real_comps(self.num_real_comps, rotate=False) + for idx_real in range(self.num_real_comps): soa_view.real[real_comp_names[idx_real]] = self.get_real_data(idx_real).to_cupy( copy=copy @@ -173,13 +178,10 @@ def soa_to_cupy(self, copy=False): int_comp_names = self.soa_int_comps(self.num_int_comps) for idx_int in range(self.num_int_comps): - soa_view.int[int_comp_names[idx_real]] = self.get_int_data(idx_int).to_cupy( + soa_view.int[int_comp_names[idx_int]] = self.get_int_data(idx_int).to_cupy( copy=copy ) - if self.has_idcpu: - soa_view.idcpu = self.get_idcpu_data().to_cupy(copy=copy) - return soa_view