Skip to content

Commit

Permalink
multi-res skeleton and demo
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahdhn committed Jul 4, 2023
1 parent f51c845 commit 686d130
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
14 changes: 7 additions & 7 deletions libNeonSkeleton/tests/unit/sUt_multiRes/src/MultiResDemo.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void MultiResDemo()
std::vector<int> gpusIds(nGPUs, 0);
auto bk = Neon::Backend(gpusIds, Neon::Runtime::stream);

const Neon::domain::mGridDescriptor descriptor({1, 1, 1, 1, 1});
Neon::mGridDescriptor<1> descriptor(5);

const float eps = std::numeric_limits<float>::epsilon();

Expand Down Expand Up @@ -129,7 +129,7 @@ void MultiResDemo()
for (int i = 0; i < descriptor.getDepth(); ++i) {
s << descriptor.getLog2RefFactor(i);
}

auto field = grid.newField<float>("myField", 1, -10000);

for (int l = 0; l < descriptor.getDepth(); ++l) {
Expand All @@ -148,10 +148,10 @@ void MultiResDemo()

for (int level = 1; level < descriptor.getDepth(); ++level) {

auto container = grid.getContainer(
auto container = grid.newContainer(
"container", level, [&, level](Neon::set::Loader& loader) {
auto& local = field.load(loader, level, Neon::MultiResCompute::MAP);
return [=] NEON_CUDA_HOST_DEVICE(const typename Neon::domain::bGrid::Cell& cell) mutable {
return [=] NEON_CUDA_HOST_DEVICE(const typename Neon::domain::mGrid::Idx& cell) mutable {
if (!local.hasChildren(cell)) {

local(cell, 0) = -1.0;
Expand All @@ -167,7 +167,7 @@ void MultiResDemo()

Neon::int8_3d child_dir(x, y, z);

val = std::max(val, local.childVal(cell, child_dir, 0, 0).value);
val = std::max(val, local.childVal(cell, child_dir, 0, 0).mData);
}
}
local(cell, 0) = val;
Expand All @@ -183,7 +183,7 @@ void MultiResDemo()

field.updateHostData();

field.ioToVtk(s.str());
field.ioToVtk(s.str(), true, true, true, false);
}


Expand All @@ -192,4 +192,4 @@ TEST(MultiRes, Demo)
if (Neon::sys::globalSpace::gpuSysObjStorage.numDevs() > 0) {
MultiResDemo();
}
}
}
16 changes: 8 additions & 8 deletions libNeonSkeleton/tests/unit/sUt_multiRes/src/MultiResSkeleton.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ void MultiResSkeleton()
const Neon::int32_3d dim(64, 64, 64);
const std::vector<int> gpusIds(nGPUs, 0);

const Neon::domain::mGridDescriptor descriptor({1, 1, 1, 1, 1});
Neon::mGridDescriptor<1> descriptor(3);


for (auto runtime : {Neon::Runtime::openmp, Neon::Runtime::stream}) {
Expand All @@ -29,7 +29,7 @@ void MultiResSkeleton()
}},
Neon::domain::Stencil::s7_Laplace_t(),
descriptor);

auto field = grid.newField<Type>("field", 3, -1);


Expand All @@ -52,13 +52,13 @@ void MultiResSkeleton()
//map operation at the top level
{
int level = descriptor.getDepth() - 1;
containers.push_back(grid.getContainer(
containers.push_back(grid.newContainer(
"map" + std::to_string(level),
level,
[&, level](Neon::set::Loader& loader) {
auto& local = field.load(loader, level, Neon::MultiResCompute::MAP);
return [=] NEON_CUDA_HOST_DEVICE(const typename Neon::domain::bGrid::Cell& cell) mutable {
Neon::index_3d global = local.mapToGlobal(cell);
return [=] NEON_CUDA_HOST_DEVICE(const typename Neon::domain::mGrid::Idx& cell) mutable {
Neon::index_3d global = local.getGlobalIndex(cell);
local(cell, 0) = global.v[0];
local(cell, 1) = global.v[1];
local(cell, 2) = global.v[2];
Expand All @@ -68,12 +68,12 @@ void MultiResSkeleton()

//all other levels
for (int level = descriptor.getDepth() - 2; level >= 0; --level) {
containers.push_back(grid.getContainer(
containers.push_back(grid.newContainer(
"ReadParent" + std::to_string(level),
level,
[&, level](Neon::set::Loader& loader) {
auto& local = field.load(loader, level, Neon::MultiResCompute::STENCIL_UP);
return [=] NEON_CUDA_HOST_DEVICE(const typename Neon::domain::bGrid::Cell& cell) mutable {
return [=] NEON_CUDA_HOST_DEVICE(const typename Neon::domain::mGrid::Idx& cell) mutable {
assert(local.hasParent(cell));

local(cell, 0) = local.parentVal(cell, 0);
Expand Down Expand Up @@ -117,4 +117,4 @@ TEST(MultiRes, Skeleton)
if (Neon::sys::globalSpace::gpuSysObjStorage.numDevs() > 0) {
MultiResSkeleton();
}
}
}

0 comments on commit 686d130

Please sign in to comment.