Commit d2f851dd authored by Martin Bauer's avatar Martin Bauer
Browse files

Added test for usage of GPU comm in Python

parent ba5733cc
from waLBerla import *
import numpy as np
import pycuda.autoinit
from pycuda.gpuarray import *
from pycuda import *
from pystencils.field import createNumpyArrayWithLayout, getLayoutOfArray
blocks = createUniformBlockGrid( cells=(1,1,1), periodic=(1,1,1) )
cuda.addGpuFieldToStorage(blocks, "gpuField", float, fSize=1, ghostLayers=1, layout=field.fzyx, usePitchedMem=False)
gpuArr = cuda.toGpuArray(blocks[0]['gpuField'])
testField = createNumpyArrayWithLayout(gpuArr.shape, getLayoutOfArray(gpuArr))
testField[...] = 0
testField[1,1,1,0] = 1
gpuArr.set(testField)
scheme = createUniformBufferedScheme(blocks, "D3Q27")
scheme.addDataToCommunicate( cuda.createPackInfo(blocks, "gpuField") )
scheme()
gpuArr = cuda.toGpuArray(blocks[0]['gpuField'])
assert(np.allclose(np.ones([3,3,3,1]), gpuArr.get()))
......@@ -103,4 +103,4 @@ namespace cuda {
} // namespace walberla
#include "FieldIndexing.impl.h"
\ No newline at end of file
#include "FieldIndexing3D.impl.h"
\ No newline at end of file
......@@ -7,18 +7,20 @@
waLBerla_compile_test( FILES communication/GPUPackInfoTest.cpp DEPENDS blockforest )
waLBerla_execute_test( NAME GPUPackInfoTest )
waLBerla_compile_test( FILES communication/CommTest )
waLBerla_execute_test( NAME CommTest )
waLBerla_compile_test( FILES FieldTransferTest )
waLBerla_execute_test( NAME FieldTransferTest )
waLBerla_compile_test( FILES SimpleKernelTest.cpp Kernels.cu DEPENDS blockforest timeloop gui )
waLBerla_execute_test( NAME SimpleKernelTest )
waLBerla_compile_test( FILES CudaMPI DEPENDS blockforest timeloop gui )
waLBerla_execute_test( NAME CudaMPI )
waLBerla_compile_test( FILES FieldIndexing3DTest.cpp FieldIndexing3DTest.cu )
waLBerla_execute_test( NAME FieldIndexing3DTest )
# The following tests work only for CUDA enabled MPI
waLBerla_compile_test( FILES communication/CommTest )
#waLBerla_execute_test( NAME CommTest PROCESSES 2)
waLBerla_compile_test( FILES CudaMPI DEPENDS blockforest timeloop gui )
#waLBerla_execute_test( NAME CudaMPI )
......@@ -228,6 +228,8 @@ int main( int argc, char ** argv )
debug::enterTestMode();
walberla::Environment walberlaEnv( argc, argv );
WALBERLA_CHECK_EQUAL(MPIManager::instance()->numProcesses(), 2);
hostToHost();
hostToDevice();
deviceToHost();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment