From 32dd41a728ce10113032e20955ba08f8de449857 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Sun, 12 Sep 2021 14:01:55 +0200 Subject: Start using C++ cuda-api-wrapper instead of raw CUDA --- tangle/ldc-2d.cu | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'tangle/ldc-2d.cu') diff --git a/tangle/ldc-2d.cu b/tangle/ldc-2d.cu index acba98f..5fa36f9 100644 --- a/tangle/ldc-2d.cu +++ b/tangle/ldc-2d.cu @@ -13,7 +13,11 @@ using T = float; using DESCRIPTOR = descriptor::D2Q9; int main() { -cudaSetDevice(0); +if (cuda::device::count() == 0) { + std::cerr << "No CUDA devices on this system" << std::endl; + return -1; +} +auto current = cuda::device::current::get(); const descriptor::Cuboid cuboid(500, 500); Lattice lattice(cuboid); @@ -52,7 +56,7 @@ while (window.isOpen()) { Operator(BounceBackMovingWallO(), lid_mask, std::min(iStep*1e-3, 1.0)*u_lid, 0.f)); lattice.stream(); if (iStep % 100 == 0) { - cudaDeviceSynchronize(); + cuda::synchronize(current); lattice.inspect(bulk_mask, moments_rho.device(), moments_u.device()); renderSliceViewToTexture<<< dim3(cuboid.nX / 32 + 1, cuboid.nY / 32 + 1), -- cgit v1.2.3