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/magnus.cu | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'tangle/magnus.cu') diff --git a/tangle/magnus.cu b/tangle/magnus.cu index 08a4515..a98bcf3 100644 --- a/tangle/magnus.cu +++ b/tangle/magnus.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(1200, 500); Lattice lattice(cuboid); @@ -64,7 +68,7 @@ auto inflow_mask = materials.mask_of_material(3); auto outflow_mask = materials.mask_of_material(4); auto edge_mask = materials.mask_of_material(5); -cudaDeviceSynchronize(); +cuda::synchronize(current); RenderWindow window("Magnus"); cudaSurfaceObject_t colormap; @@ -83,7 +87,7 @@ while (window.isOpen()) { lattice.apply(bouzidi.getCount(), bouzidi.getConfig()); lattice.stream(); if (iStep % 200 == 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