mirror of
https://github.com/NGSolve/netgen.git
synced 2025-01-24 03:40:34 +05:00
Merge branch 'enable_catch_tests' into 'master'
enable catch unit tests See merge request jschoeberl/netgen!208
This commit is contained in:
commit
0e601b3db4
@ -22,6 +22,7 @@ stages:
|
|||||||
- set SRC_DIR=%CI_DIR%\src
|
- set SRC_DIR=%CI_DIR%\src
|
||||||
- set NETGENDIR=%INSTALL_DIR%\bin
|
- set NETGENDIR=%INSTALL_DIR%\bin
|
||||||
- set PYTHONPATH=%INSTALL_DIR%\lib\site-packages
|
- set PYTHONPATH=%INSTALL_DIR%\lib\site-packages
|
||||||
|
- set PATH=%NETGENDIR%;%PATH%
|
||||||
|
|
||||||
build_win:
|
build_win:
|
||||||
<<: *win
|
<<: *win
|
||||||
@ -40,6 +41,7 @@ build_win:
|
|||||||
-DCMAKE_INSTALL_PREFIX=%INSTALL_DIR%
|
-DCMAKE_INSTALL_PREFIX=%INSTALL_DIR%
|
||||||
-DUSE_OCC=ON
|
-DUSE_OCC=ON
|
||||||
-DUSE_CCACHE=ON
|
-DUSE_CCACHE=ON
|
||||||
|
-DENABLE_UNIT_TESTS=ON
|
||||||
-DCMAKE_BUILD_TYPE=Release
|
-DCMAKE_BUILD_TYPE=Release
|
||||||
- cmake --build . --target install --config Release
|
- cmake --build . --target install --config Release
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
cd
|
cd
|
||||||
mkdir -p build/netgen
|
mkdir -p build/netgen
|
||||||
cd build/netgen
|
cd build/netgen
|
||||||
cmake ../../src/netgen -DUSE_CCACHE=ON -DBUILD_TYPE=DEBUG
|
cmake ../../src/netgen -DUSE_CCACHE=ON -DBUILD_TYPE=DEBUG -DENABLE_UNIT_TESTS=ON
|
||||||
make -j12
|
make -j12
|
||||||
make install
|
make install
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
cd
|
cd
|
||||||
mkdir -p build/netgen
|
mkdir -p build/netgen
|
||||||
cd build/netgen
|
cd build/netgen
|
||||||
cmake ../../src/netgen -DUSE_CCACHE=ON -DUSE_MPI=ON
|
cmake ../../src/netgen -DUSE_CCACHE=ON -DUSE_MPI=ON -DENABLE_UNIT_TESTS=ON
|
||||||
make -j12
|
make -j12
|
||||||
make install
|
make install
|
||||||
|
@ -14,7 +14,7 @@ add_test(NAME unit_tests_built COMMAND ${CMAKE_COMMAND} --build . --target unit_
|
|||||||
|
|
||||||
macro(add_unit_test name sources)
|
macro(add_unit_test name sources)
|
||||||
add_executable(test_${name} ${sources} )
|
add_executable(test_${name} ${sources} )
|
||||||
target_link_libraries(test_${name} ngcore catch_main ${PYTHON_LIBRARIES})
|
target_link_libraries(test_${name} ngcore catch_main nglib ${PYTHON_LIBRARIES})
|
||||||
|
|
||||||
add_dependencies(unit_tests test_${name})
|
add_dependencies(unit_tests test_${name})
|
||||||
add_test(NAME unit_${name} COMMAND test_${name})
|
add_test(NAME unit_${name} COMMAND test_${name})
|
||||||
|
@ -5,9 +5,9 @@ using namespace ngcore;
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
long shuffle(long N, long i) {
|
uint64_t shuffle(uint64_t N, uint64_t i) {
|
||||||
// Shuffle the numbers using multiplication with a prime number to force many updates of min, max
|
// Shuffle the numbers using multiplication with a prime number to force many updates of min, max
|
||||||
constexpr long P = 101;
|
constexpr uint64_t P = 101;
|
||||||
return (N/2 + i*P) % N;
|
return (N/2 + i*P) % N;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -16,29 +16,29 @@ void testThreading(int n_threads)
|
|||||||
TaskManager::SetNumThreads(n_threads);
|
TaskManager::SetNumThreads(n_threads);
|
||||||
n_threads = EnterTaskManager();
|
n_threads = EnterTaskManager();
|
||||||
|
|
||||||
constexpr long N = 100000;
|
constexpr uint64_t N = 100000;
|
||||||
|
|
||||||
|
|
||||||
SECTION( "atomic operations" ) {
|
SECTION( "atomic operations" ) {
|
||||||
long i_min = 2*N;
|
uint64_t i_min = 2*N;
|
||||||
long i_max = 0;
|
uint64_t i_max = 0;
|
||||||
long i_sum = 0;
|
uint64_t i_sum = 0;
|
||||||
|
|
||||||
double d_min = 1e100;
|
double d_min = 1e100;
|
||||||
double d_max = 0.0;
|
double d_max = 0.0;
|
||||||
double d_sum = 0.0;
|
double d_sum = 0.0;
|
||||||
|
|
||||||
ParallelFor( Range(N), [&] (long i) {
|
ParallelFor( Range(N), [&] (uint64_t i) {
|
||||||
AtomicMin(i_min, shuffle(N,i));
|
AtomicMin(i_min, shuffle(N,i));
|
||||||
});
|
});
|
||||||
REQUIRE( i_min==0 );
|
REQUIRE( i_min==0 );
|
||||||
|
|
||||||
ParallelFor( Range(N), [&] (long i) {
|
ParallelFor( Range(N), [&] (uint64_t i) {
|
||||||
AtomicMax(i_max, shuffle(N,i));
|
AtomicMax(i_max, shuffle(N,i));
|
||||||
});
|
});
|
||||||
REQUIRE( i_max==N-1 );
|
REQUIRE( i_max==N-1 );
|
||||||
|
|
||||||
ParallelFor( Range(N), [&] (long i) {
|
ParallelFor( Range(N), [&] (uint64_t i) {
|
||||||
AsAtomic(i_sum) += i;
|
AsAtomic(i_sum) += i;
|
||||||
});
|
});
|
||||||
REQUIRE( i_sum==N*(N-1)/2 );
|
REQUIRE( i_sum==N*(N-1)/2 );
|
||||||
|
Loading…
Reference in New Issue
Block a user