Skip to content
Snippets Groups Projects
Commit 9990ed19 authored by Anna Wellmann's avatar Anna Wellmann
Browse files

Merge branch 'fixTests' into 'develop'

Update CMakeList for VF_GPU and remove a unit test for Parameter.cpp

See merge request irmb/VirtualFluids_dev!234
parents 3f83442a 5baed6ed
No related branches found
No related tags found
1 merge request!234Update CMakeList for VF_GPU and remove a unit test for Parameter.cpp
project(VirtualFluids_GPU LANGUAGES CUDA CXX)
find_package(CUDA REQUIRED)
include_directories("${CUDA_INCLUDE_DIRS}")
set(additional_libraries "")
if(MSVC)
set(additional_libraries ws2_32 Traffic) # ws_32 throws an error on Phoenix
......@@ -20,10 +17,13 @@ vf_add_tests()
if(BUILD_VF_UNIT_TESTS)
set_target_properties(VirtualFluids_GPUTests PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
set_source_files_properties(Kernel/Utilities/DistributionHelperTests.cpp PROPERTIES LANGUAGE CUDA)
set_source_files_properties(DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreamsTest.cpp PROPERTIES LANGUAGE CUDA)
set_source_files_properties(Communication/ExchangeData27Test.cpp PROPERTIES LANGUAGE CUDA)
set_source_files_properties(BoundaryConditions/BoundaryConditionFactoryTest.cpp PROPERTIES LANGUAGE CUDA)
target_include_directories(VirtualFluids_GPUTests PRIVATE "${VF_THIRD_DIR}/cuda_samples/")
target_include_directories(VirtualFluids_GPUTests PRIVATE "${VF_ROOT_DIR}/src/gpu/GridGenerator/")
set_source_files_properties(Communication/ExchangeData27Test.cpp PROPERTIES LANGUAGE CUDA)
set_source_files_properties(Factories/BoundaryConditionFactoryTest.cpp PROPERTIES LANGUAGE CUDA)
set_source_files_properties(DataStructureInitializer/GridReaderGenerator/GridGeneratorTest.cpp PROPERTIES LANGUAGE CUDA)
set_source_files_properties(DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreamsTest.cpp PROPERTIES LANGUAGE CUDA)
set_source_files_properties(Kernel/Kernels/BasicKernels/FluidFlow/Compressible/CumulantK17/CumulantK17Test.cpp PROPERTIES LANGUAGE CUDA)
set_source_files_properties(Kernel/Utilities/DistributionHelperTests.cpp PROPERTIES LANGUAGE CUDA)
set_source_files_properties(Parameter/ParameterTest.cpp PROPERTIES LANGUAGE CUDA)
endif()
......@@ -250,64 +250,6 @@ TEST(ParameterTest, whenCreatingParameterClassWithGridRefinement_afterCallingIni
EXPECT_THAT(para->getParH(1), testing::Ne(nullptr));
}
class MockCommunicator : public vf::gpu::Communicator
{
public:
void waitAll() override {};
int getPID() const override
{
return 0;
};
int getNumberOfProcess() const override
{
return 1;
};
void exchngData(float *sbuf_t, float *rbuf_t, float *sbuf_b, float *rbuf_b, int count) override {};
//////////////////////////////////////////////////////////////////////////
void exchngDataGPU(real *sbuf, int count_s, real *rbuf, int count_r, int nb_rank) override {};
void nbRecvDataGPU(real *rbuf, int count_r, int nb_rank) override {};
void nbSendDataGPU(real *sbuf, int count_s, int nb_rank) override {};
void waitallGPU() override {};
void sendDataGPU(real *sbuf, int count_s, int nb_rank) override {};
void waitGPU(int id) override {};
void resetRequest() override {};
//////////////////////////////////////////////////////////////////////////
int mapCudaDevice(const int &rank, const int &size, const std::vector<unsigned int> &devices, const int &maxdev) override
{
return 0;
};
double reduceSum(double quantityPerProcess) override
{
return 0;
};
//////////////////////////////////////////////////////////////////////////
void receive_send(uint *buffer_receive, int size_buffer_recv, int neighbor_rank_recv, uint *buffer_send, int size_buffer_send, int neighbor_rank_send) const override {};
};
TEST(ParameterTest, whenCreatingParameterClassWithGridRefinement_afterCallingSimulationConstructor_shouldNotThrow)
{
spdlog::set_level(spdlog::level::warn); // avoids logger spam in output
auto para = std::make_shared<Parameter>();
para->setMaxLevel(2);
SPtr<CudaMemoryManager> cudaMemoryManager = std::make_shared<CudaMemoryManager>(para);
MockCommunicator communicator = MockCommunicator();
auto gridFactory = GridFactory::make();
auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory);
SPtr<GridProvider> gridGenerator =
std::make_shared<MockGridGenerator>(gridBuilder, para, cudaMemoryManager, communicator);
BoundaryConditionFactory bcFactory = BoundaryConditionFactory();
GridScalingFactory scalingFactory = GridScalingFactory();
EXPECT_THAT(para->getParH(1), testing::Eq(nullptr)); // Parameter initialization incomplete
// Simulation() calls para->initLBMSimulationParameter() --> that function completes the initialization of Parameter
Simulation sim(para, cudaMemoryManager, communicator, *gridGenerator, &bcFactory, &scalingFactory);
EXPECT_THAT(para->getParH(1), testing::Ne(nullptr));
EXPECT_NO_THROW(cudaMemoryManager->cudaAllocLevelForcing(1)); // throws if para->getParH(1) is a null pointer
}
class ParameterTestCumulantK17 : public testing::Test
{
protected:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment