From 7cc6bbddd9260ddb613514976e295f23a0b7bbb3 Mon Sep 17 00:00:00 2001 From: iyamazaki Date: Tue, 14 Dec 2021 09:11:27 -0700 Subject: [PATCH] MueLu : put getDataNonConst in a separate scope to avoid "Cannot access data on device while a host view is alive" error --- .../test/unit_tests/NullspaceFactory.cpp | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/packages/muelu/test/unit_tests/NullspaceFactory.cpp b/packages/muelu/test/unit_tests/NullspaceFactory.cpp index 452f82257e74..0295e927ba22 100644 --- a/packages/muelu/test/unit_tests/NullspaceFactory.cpp +++ b/packages/muelu/test/unit_tests/NullspaceFactory.cpp @@ -117,16 +117,18 @@ namespace MueLuTests { size_t nullDim = 6; RCP handCompNullSpace = MultiVectorFactory::Build(Op->getRowMap(), nullDim); handCompNullSpace->putScalar(0.0); - ArrayRCP nsValues; - nsValues = handCompNullSpace->getDataNonConst(0); for (int j = 0; j < nsValues.size(); j +=3) nsValues[j] = 1.; - nsValues = handCompNullSpace->getDataNonConst(1); for (int j = 1; j < nsValues.size(); j +=3) nsValues[j] = 1.; - nsValues = handCompNullSpace->getDataNonConst(2); for (int j = 2; j < nsValues.size(); j +=3) nsValues[j] = 1.; - nsValues = handCompNullSpace->getDataNonConst(3); for (int j = 0; j < nsValues.size(); j +=3) nsValues[j] = -(yvals[j/3]-.5); - for (int j = 1; j < nsValues.size(); j +=3) nsValues[j] = (xvals[j/3]-.5); - nsValues = handCompNullSpace->getDataNonConst(4); for (int j = 1; j < nsValues.size(); j +=3) nsValues[j] = -(zvals[j/3]-.5); - for (int j = 2; j < nsValues.size(); j +=3) nsValues[j] = (yvals[j/3]-.5); - nsValues = handCompNullSpace->getDataNonConst(5); for (int j = 0; j < nsValues.size(); j +=3) nsValues[j] = -(zvals[j/3]-.5); - for (int j = 2; j < nsValues.size(); j +=3) nsValues[j] = (xvals[j/3]-.5); + { + ArrayRCP nsValues; + nsValues = handCompNullSpace->getDataNonConst(0); for (int j = 0; j < nsValues.size(); j +=3) nsValues[j] = 1.; + nsValues = handCompNullSpace->getDataNonConst(1); for (int j = 1; j < nsValues.size(); j +=3) nsValues[j] = 1.; + nsValues = handCompNullSpace->getDataNonConst(2); for (int j = 2; j < nsValues.size(); j +=3) nsValues[j] = 1.; + nsValues = handCompNullSpace->getDataNonConst(3); for (int j = 0; j < nsValues.size(); j +=3) nsValues[j] = -(yvals[j/3]-.5); + for (int j = 1; j < nsValues.size(); j +=3) nsValues[j] = (xvals[j/3]-.5); + nsValues = handCompNullSpace->getDataNonConst(4); for (int j = 1; j < nsValues.size(); j +=3) nsValues[j] = -(zvals[j/3]-.5); + for (int j = 2; j < nsValues.size(); j +=3) nsValues[j] = (yvals[j/3]-.5); + nsValues = handCompNullSpace->getDataNonConst(5); for (int j = 0; j < nsValues.size(); j +=3) nsValues[j] = -(zvals[j/3]-.5); + for (int j = 2; j < nsValues.size(); j +=3) nsValues[j] = (xvals[j/3]-.5); + } RCP diff = MultiVectorFactory::Build(Op->getRowMap(),6); diff->putScalar(0.0);