Skip to content

Commit 52b6c97

Browse files
[FIX] compatibility with compiling on AMD Instinct MI300A APU (#360)
* [FIX] compatibility with compiling on AMD Instinct MI300A APU * `pre-commit` linter fix
1 parent e289365 commit 52b6c97

File tree

7 files changed

+48
-43
lines changed

7 files changed

+48
-43
lines changed

src/dataBlock/dataBlockHost.cpp

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ DataBlockHost::DataBlockHost(DataBlock& datain) {
2121

2222
// Create mirrors (should be mirror_view)
2323
for(int dir = 0 ; dir < 3 ; dir++) {
24-
x[dir] = Kokkos::create_mirror_view(data->x[dir]);
25-
xr[dir] = Kokkos::create_mirror_view(data->xr[dir]);
26-
xl[dir] = Kokkos::create_mirror_view(data->xl[dir]);
27-
dx[dir] = Kokkos::create_mirror_view(data->dx[dir]);
28-
A[dir] = Kokkos::create_mirror_view(data->A[dir]);
24+
x[dir] = Kokkos::create_mirror_view(Kokkos::HostSpace(), data->x[dir]);
25+
xr[dir] = Kokkos::create_mirror_view(Kokkos::HostSpace(), data->xr[dir]);
26+
xl[dir] = Kokkos::create_mirror_view(Kokkos::HostSpace(), data->xl[dir]);
27+
dx[dir] = Kokkos::create_mirror_view(Kokkos::HostSpace(), data->dx[dir]);
28+
A[dir] = Kokkos::create_mirror_view(Kokkos::HostSpace(), data->A[dir]);
2929
}
3030

3131
np_tot = data->np_tot;
@@ -47,30 +47,30 @@ DataBlockHost::DataBlockHost(DataBlock& datain) {
4747

4848
// TO BE COMPLETED...
4949

50-
dV = Kokkos::create_mirror_view(data->dV);
51-
Vc = Kokkos::create_mirror_view(data->hydro->Vc);
52-
Uc = Kokkos::create_mirror_view(data->hydro->Uc);
53-
InvDt = Kokkos::create_mirror_view(data->hydro->InvDt);
50+
dV = Kokkos::create_mirror_view(Kokkos::HostSpace(), data->dV);
51+
Vc = Kokkos::create_mirror_view(Kokkos::HostSpace(), data->hydro->Vc);
52+
Uc = Kokkos::create_mirror_view(Kokkos::HostSpace(), data->hydro->Uc);
53+
InvDt = Kokkos::create_mirror_view(Kokkos::HostSpace(), data->hydro->InvDt);
5454

5555
#if MHD == YES
56-
Vs = Kokkos::create_mirror_view(data->hydro->Vs);
56+
Vs = Kokkos::create_mirror_view(Kokkos::HostSpace(), data->hydro->Vs);
5757
this->haveCurrent = data->hydro->haveCurrent;
5858
if(data->hydro->haveCurrent) {
59-
J = Kokkos::create_mirror_view(data->hydro->J);
59+
J = Kokkos::create_mirror_view(Kokkos::HostSpace(), data->hydro->J);
6060
}
6161
#ifdef EVOLVE_VECTOR_POTENTIAL
62-
Ve = Kokkos::create_mirror_view(data->hydro->Ve);
62+
Ve = Kokkos::create_mirror_view(Kokkos::HostSpace(), data->hydro->Ve);
6363
#endif
6464

65-
D_EXPAND( Ex3 = Kokkos::create_mirror_view(data->hydro->emf->ez); ,
65+
D_EXPAND( Ex3 = Kokkos::create_mirror_view(Kokkos::HostSpace(), data->hydro->emf->ez); ,
6666
,
67-
Ex1 = Kokkos::create_mirror_view(data->hydro->emf->ex);
68-
Ex2 = Kokkos::create_mirror_view(data->hydro->emf->ey); )
67+
Ex1 = Kokkos::create_mirror_view(Kokkos::HostSpace(), data->hydro->emf->ex);
68+
Ex2 = Kokkos::create_mirror_view(Kokkos::HostSpace(), data->hydro->emf->ey); )
6969
#endif
7070
if(haveDust) {
7171
dustVc = std::vector<IdefixHostArray4D<real>>(data->dust.size());
7272
for(int i = 0 ; i < data->dust.size() ; i++) {
73-
dustVc[i] = Kokkos::create_mirror_view(data->dust[i]->Vc);
73+
dustVc[i] = Kokkos::create_mirror_view(Kokkos::HostSpace(), data->dust[i]->Vc);
7474
}
7575
}
7676

@@ -80,7 +80,8 @@ DataBlockHost::DataBlockHost(DataBlock& datain) {
8080
this->coarseningDirection = data->coarseningDirection;
8181
for(int dir = 0 ; dir < 3 ; dir++) {
8282
if(coarseningDirection[dir]) {
83-
coarseningLevel[dir] = Kokkos::create_mirror_view(data->coarseningLevel[dir]);
83+
coarseningLevel[dir] = Kokkos::create_mirror_view(Kokkos::HostSpace(),
84+
data->coarseningLevel[dir]);
8485
}
8586
}
8687
}

src/dataBlock/dumpToFile.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,15 @@ void DataBlock::DumpToFile(std::string filebase) {
4545

4646

4747
// TODO(lesurg) Make datablock a friend of hydro to get the Riemann flux?
48-
//IdefixArray4D<real>::HostMirror locFlux = Kokkos::create_mirror_view(this->hydro->FluxRiemann);
48+
//IdefixArray4D<real>::HostMirror locFlux = Kokkos::create_mirror_view(Kokkos::HostSpace(),
49+
// this->hydro->FluxRiemann);
4950
//Kokkos::deep_copy(locFlux, this->FluxRiemann);
5051
#if MHD == YES
5152

5253

5354
IdefixArray4D<real>::HostMirror locJ;
5455
if(hydro->haveCurrent) {
55-
locJ = Kokkos::create_mirror_view(this->hydro->J);
56+
locJ = Kokkos::create_mirror_view(Kokkos::HostSpace(), this->hydro->J);
5657
Kokkos::deep_copy(locJ, this->hydro->J);
5758
}
5859
#endif
@@ -120,7 +121,8 @@ void DataBlock::DumpToFile(std::string filebase) {
120121
// Write Vs
121122
#if MHD == YES
122123
// Write Vs
123-
IdefixArray4D<real>::HostMirror locVs = Kokkos::create_mirror_view(this->hydro->Vs);
124+
IdefixArray4D<real>::HostMirror locVs = Kokkos::create_mirror_view(Kokkos::HostSpace(),
125+
this->hydro->Vs);
124126
Kokkos::deep_copy(locVs,this->hydro->Vs);
125127
dims[0] = this->np_tot[IDIR]+IOFFSET;
126128
dims[1] = this->np_tot[JDIR]+JOFFSET;
@@ -137,7 +139,8 @@ void DataBlock::DumpToFile(std::string filebase) {
137139
dims[2] = this->np_tot[KDIR];
138140

139141
std::snprintf(fieldName,NAMESIZE,"Ex3");
140-
IdefixArray3D<real>::HostMirror locE = Kokkos::create_mirror_view(this->hydro->emf->ez);
142+
IdefixArray3D<real>::HostMirror locE = Kokkos::create_mirror_view(Kokkos::HostSpace(),
143+
this->hydro->emf->ez);
141144
Kokkos::deep_copy(locE,this->hydro->emf->ez);
142145
WriteVariable(fileHdl, 3, dims, fieldName, locE.data());
143146

@@ -152,7 +155,8 @@ void DataBlock::DumpToFile(std::string filebase) {
152155

153156

154157
if(hydro->haveCurrent) {
155-
IdefixArray4D<real>::HostMirror locJ = Kokkos::create_mirror_view(this->hydro->J);
158+
IdefixArray4D<real>::HostMirror locJ = Kokkos::create_mirror_view(Kokkos::HostSpace(),
159+
this->hydro->J);
156160
Kokkos::deep_copy(locJ,this->hydro->J);
157161
dims[0] = this->np_tot[IDIR];
158162
dims[1] = this->np_tot[JDIR];

src/fluid/checkNan.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ int Fluid<Phys>::CheckNan() {
6767

6868
DataBlockHost dataHost(*data);
6969

70-
IdefixHostArray4D<real> VcHost = Kokkos::create_mirror_view(this->Vc);
70+
IdefixHostArray4D<real> VcHost = Kokkos::create_mirror_view(Kokkos::HostSpace(), this->Vc);
7171
Kokkos::deep_copy(VcHost,Vc);
7272

7373
int nerrormax=10;
@@ -95,7 +95,7 @@ int Fluid<Phys>::CheckNan() {
9595
}
9696

9797
if constexpr(Phys::mhd) {
98-
IdefixHostArray4D<real> VsHost = Kokkos::create_mirror_view(this->Vs);
98+
IdefixHostArray4D<real> VsHost = Kokkos::create_mirror_view(Kokkos::HostSpace(), this->Vs);
9999
Kokkos::deep_copy(VsHost,Vs);
100100
for(int k = data->beg[KDIR] ; k < data->end[KDIR]+KOFFSET ; k++) {
101101
for(int j = data->beg[JDIR] ; j < data->end[JDIR]+JOFFSET ; j++) {

src/grid.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class SubGrid {
8181
parentGrid(grid), type(type), direction(d) {
8282
idfx::pushRegion("SubGrid::SubGrid()");
8383
// Find the index of the current subgrid.
84-
auto x = Kokkos::create_mirror_view(parentGrid->x[direction]);
84+
auto x = Kokkos::create_mirror_view(Kokkos::HostSpace(), parentGrid->x[direction]);
8585
Kokkos::deep_copy(x,parentGrid->x[direction]);
8686
int iref = -1;
8787
for(int i = 0 ; i < x.extent(0) - 1 ; i++) {

src/gridHost.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ GridHost::GridHost(Grid &grid) {
3232

3333
// Create mirrors on host
3434
for(int dir = 0 ; dir < 3 ; dir++) {
35-
x[dir] = Kokkos::create_mirror_view(grid.x[dir]);
36-
xr[dir] = Kokkos::create_mirror_view(grid.xr[dir]);
37-
xl[dir] = Kokkos::create_mirror_view(grid.xl[dir]);
38-
dx[dir] = Kokkos::create_mirror_view(grid.dx[dir]);
35+
x[dir] = Kokkos::create_mirror_view(Kokkos::HostSpace(), grid.x[dir]);
36+
xr[dir] = Kokkos::create_mirror_view(Kokkos::HostSpace(), grid.xr[dir]);
37+
xl[dir] = Kokkos::create_mirror_view(Kokkos::HostSpace(), grid.xl[dir]);
38+
dx[dir] = Kokkos::create_mirror_view(Kokkos::HostSpace(), grid.dx[dir]);
3939
}
4040

4141
idfx::popRegion();

src/output/dump.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,13 @@ class DumpField {
8888
h4Darray, var, Kokkos::ALL, Kokkos::ALL, Kokkos::ALL);
8989
return(arr3D);
9090
} else if(arrayType==Device3D) {
91-
IdefixHostArray3D<real> arr3D = Kokkos::create_mirror(d3Darray);
91+
IdefixHostArray3D<real> arr3D = Kokkos::create_mirror(Kokkos::HostSpace(), d3Darray);
9292
Kokkos::deep_copy(arr3D,d3Darray);
9393
return(arr3D);
9494
} else if(arrayType==Device4D) {
9595
IdefixArray3D<real> arrDev3D = Kokkos::subview(
9696
d4Darray, var, Kokkos::ALL, Kokkos::ALL, Kokkos::ALL);
97-
IdefixHostArray3D<real> arr3D = Kokkos::create_mirror(arrDev3D);
97+
IdefixHostArray3D<real> arr3D = Kokkos::create_mirror(Kokkos::HostSpace(), arrDev3D);
9898
Kokkos::deep_copy(arr3D,arrDev3D);
9999
return(arr3D);
100100
} else {

src/utils/lookupTable.hpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,10 @@ LookupTable<kDim>::LookupTable(std::vector<std::string> filenames,
183183
this->offsetDev = IdefixArray1D<int> ("Table_offset", kDim);
184184
this->dataDev = IdefixArray1D<real> ("Table_data", dataVector.size());
185185

186-
this->xinHost = Kokkos::create_mirror_view(this->xinDev);
187-
this->dimensionsHost = Kokkos::create_mirror_view(this->dimensionsDev);
188-
this->offsetHost = Kokkos::create_mirror_view(this->offsetDev);
189-
this->dataHost = Kokkos::create_mirror_view(this->dataDev);
186+
this->xinHost = Kokkos::create_mirror_view(Kokkos::HostSpace(), this->xinDev);
187+
this->dimensionsHost = Kokkos::create_mirror_view(Kokkos::HostSpace(), this->dimensionsDev);
188+
this->offsetHost = Kokkos::create_mirror_view(Kokkos::HostSpace(), this->offsetDev);
189+
this->dataHost = Kokkos::create_mirror_view(Kokkos::HostSpace(), this->dataDev);
190190

191191
// Copy data in memory
192192
for(uint64_t i = 0 ; i < dataVector.size() ; i++) {
@@ -346,10 +346,10 @@ LookupTable<kDim>::LookupTable(std::string filename, char delimiter, bool errOOB
346346
this->offsetDev = IdefixArray1D<int> ("Table_offset", kDim);
347347
this->dataDev = IdefixArray1D<real> ("Table_data", size[0]*size[1]);
348348

349-
this->xinHost = Kokkos::create_mirror_view(this->xinDev);
350-
this->dimensionsHost = Kokkos::create_mirror_view(this->dimensionsDev);
351-
this->offsetHost = Kokkos::create_mirror_view(this->offsetDev);
352-
this->dataHost = Kokkos::create_mirror_view(this->dataDev);
349+
this->xinHost = Kokkos::create_mirror_view(Kokkos::HostSpace(), this->xinDev);
350+
this->dimensionsHost = Kokkos::create_mirror_view(Kokkos::HostSpace(), this->dimensionsDev);
351+
this->offsetHost = Kokkos::create_mirror_view(Kokkos::HostSpace(), this->offsetDev);
352+
this->dataHost = Kokkos::create_mirror_view(Kokkos::HostSpace(), this->dataDev);
353353

354354
// Fill the arrays with the std::vector content
355355
if(idfx::prank == 0) {
@@ -458,10 +458,10 @@ LookupTable<kDim>::LookupTable(Kokkos::View<T, Args...> array,
458458
this->offsetDev = IdefixArray1D<int> ("Table_offset", kDim);
459459
this->dataDev = IdefixArray1D<real> ("Table_data", sizeTotal);
460460

461-
this->xinHost = Kokkos::create_mirror_view(this->xinDev);
462-
this->dimensionsHost = Kokkos::create_mirror_view(this->dimensionsDev);
463-
this->offsetHost = Kokkos::create_mirror_view(this->offsetDev);
464-
this->dataHost = Kokkos::create_mirror_view(this->dataDev);
461+
this->xinHost = Kokkos::create_mirror_view(Kokkos::HostSpace(), this->xinDev);
462+
this->dimensionsHost = Kokkos::create_mirror_view(Kokkos::HostSpace(), this->dimensionsDev);
463+
this->offsetHost = Kokkos::create_mirror_view(Kokkos::HostSpace(), this->offsetDev);
464+
this->dataHost = Kokkos::create_mirror_view(Kokkos::HostSpace(), this->dataDev);
465465

466466
// Copy data in memory
467467
for(uint64_t n = 0 ; n < sizeTotal ; n++) {

0 commit comments

Comments
 (0)