Skip to content

Commit f21bf6e

Browse files
committed
remove unused var
1 parent 236281d commit f21bf6e

File tree

8 files changed

+191
-8
lines changed

8 files changed

+191
-8
lines changed

benchmark/test/CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12)
144144

145145
if(NOT DEFINED PyOK)
146146
execute_process(COMMAND ${Python_EXECUTABLE} -c "import h5py,numpy,pandas,matplotlib"
147-
TIMEOUT 10
148147
RESULT_VARIABLE ret
149148
)
150149
if(ret EQUAL 0)

example/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ add_executable(example1 example1.f90)
1313
target_link_libraries(example1 h5fortran::h5fortran MPI::MPI_Fortran MPI::MPI_C)
1414

1515
add_test(NAME Example1 COMMAND example1)
16+
1617
set_property(TEST Example1 PROPERTY WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
17-
set_property(TEST Example1 PROPERTY PROPERTY TIMEOUT 30)

memcheck.cmake

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# run like:
2+
#
3+
# ctest -S memcheck.cmake
4+
#
5+
# optionally, tell path to memory checker like:
6+
#
7+
# ctest -DMEMCHECK_ROOT=/path/to/bin/valgrind -S memcheck.cmake
8+
9+
list(APPEND opts -DCMAKE_BUILD_TYPE=Debug)
10+
11+
set(CTEST_TEST_TIMEOUT 60)
12+
# takes effect only if test property TIMEOUT is not set
13+
14+
if(NOT DEFINED CTEST_MEMORYCHECK_TYPE)
15+
set(CTEST_MEMORYCHECK_TYPE "Valgrind")
16+
endif()
17+
18+
if(CTEST_MEMORYCHECK_TYPE STREQUAL "Valgrind")
19+
# https://www.cprogramming.com/debugging/valgrind.html
20+
find_program(exe NAMES valgrind HINTS ${MEMCHECK_ROOT} PATH_SUFFIXES bin REQUIRED)
21+
set(CTEST_MEMORYCHECK_COMMAND ${exe})
22+
set(supp ${CMAKE_CURRENT_LIST_DIR}/valgrind.supp)
23+
if(EXISTS ${supp})
24+
set(CTEST_MEMORYCHECK_COMMAND_OPTIONS --suppressions=${supp})
25+
endif()
26+
elseif(CTEST_MEMORYCHECK_TYPE STREQUAL "DrMemory")
27+
find_program(exe NAMES drmemory HINTS ${MEMCHECK_ROOT} PATH_SUFFIXES bin64 bin REQUIRED)
28+
set(CTEST_MEMORYCHECK_COMMAND ${exe})
29+
set(CTEST_MEMORYCHECK_COMMAND_OPTIONS "-light -count_leaks")
30+
elseif(CTEST_MEMORYCHECK_TYPE STREQUAL "AddressSanitizer")
31+
set(check_flags -fsanitize=address)
32+
elseif(CTEST_MEMORYCHECK_TYPE STREQUAL "LeakSanitizer")
33+
set(check_flags -fsanitize=leak)
34+
elseif(CTEST_MEMORYCHECK_TYPE STREQUAL "MemorySanitizer")
35+
set(check_flags -fsanitize=memory)
36+
elseif(CTEST_MEMORYCHECK_TYPE STREQUAL "ThreadSanitizer")
37+
set(check_flags -fsanitize=thread)
38+
elseif(CTEST_MEMORYCHECK_TYPE STREQUAL "UndefinedBehaviorSanitizer")
39+
set(check_flags -fsanitize=undefined)
40+
else()
41+
message(FATAL_ERROR "Unknown memory checker type: ${CTEST_MEMORYCHECK_TYPE}")
42+
endif()
43+
44+
if(check_flags)
45+
list(APPEND opts
46+
-DCMAKE_C_FLAGS_DEBUG=${check_flags}
47+
-DCMAKE_CXX_FLAGS_DEBUG=${check_flags}
48+
-DCMAKE_EXE_LINKER_FLAGS_INIT=${check_flags}
49+
)
50+
endif()
51+
52+
set(CTEST_SOURCE_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
53+
set(CTEST_BINARY_DIRECTORY ${CTEST_SOURCE_DIRECTORY}/build-${CTEST_MEMORYCHECK_TYPE})
54+
set(CTEST_BUILD_CONFIGURATION Debug)
55+
56+
if(WIN32)
57+
set(CTEST_CMAKE_GENERATOR "MinGW Makefiles")
58+
else()
59+
set(CTEST_CMAKE_GENERATOR "Unix Makefiles")
60+
endif()
61+
set(CTEST_BUILD_FLAGS -j)
62+
63+
message(STATUS "Checker ${CTEST_MEMORYCHECK_TYPE}: ${CTEST_MEMORYCHECK_COMMAND}")
64+
65+
ctest_start(Experimental)
66+
67+
ctest_configure(
68+
OPTIONS "${opts}"
69+
RETURN_VALUE ret
70+
CAPTURE_CMAKE_ERROR err
71+
)
72+
if(NOT (ret EQUAL 0 AND err EQUAL 0))
73+
message(FATAL_ERROR "CMake configure failed: ${ret} ${err}")
74+
endif()
75+
76+
cmake_host_system_information(RESULT Ncpu QUERY NUMBER_OF_PHYSICAL_CORES)
77+
78+
ctest_build(
79+
PARALLEL_LEVEL ${Ncpu}
80+
RETURN_VALUE ret
81+
CAPTURE_CMAKE_ERROR err
82+
)
83+
if(NOT (ret EQUAL 0 AND err EQUAL 0))
84+
message(FATAL_ERROR "CMake build failed: ${ret} ${err}")
85+
endif()
86+
87+
ctest_memcheck(
88+
INCLUDE ${include}
89+
INCLUDE_LABEL ${include_label}
90+
EXCLUDE ${exclude}
91+
EXCLUDE_LABEL ${exclude_label}
92+
RETURN_VALUE ret
93+
CAPTURE_CMAKE_ERROR err
94+
DEFECT_COUNT count
95+
)
96+
97+
if(NOT (ret EQUAL 0 AND err EQUAL 0))
98+
message(FATAL_ERROR "Memory check failed: ${ret} ${err}")
99+
endif()
100+
101+
if(NOT count EQUAL 0)
102+
message(FATAL_ERROR "Memory check found ${count} defects")
103+
endif()

test/CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
2+
add_compile_options("$<$<COMPILE_LANGUAGE:Fortran>:-Wno-compare-reals;-Wno-maybe-uninitialized>")
3+
endif()
4+
15
add_library(cpu_count OBJECT cpu_count.cpp)
26
target_compile_features(cpu_count PRIVATE cxx_std_11)
37
target_compile_definitions(cpu_count PRIVATE $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>)

test/cpu_count.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ unsigned int cpu_count(){
9191
unsigned int CPUCountWindows(){
9292

9393
unsigned int NumberOfPhysicalCPU = 0;
94-
unsigned int NumberOfLogicalCPU = 0;
9594

9695
#ifdef _WIN32
9796

@@ -133,7 +132,6 @@ unsigned int CPUCountWindows(){
133132
continue;
134133
}
135134
NumberOfPhysicalCPU++;
136-
NumberOfLogicalCPU += (unsigned int)count;
137135
}
138136

139137
#endif
@@ -145,7 +143,6 @@ unsigned int CPUCountWindows(){
145143

146144
unsigned int RetrieveInformationFromCpuInfoFile(){
147145

148-
unsigned int NumberOfLogicalCPU = 0;
149146
unsigned int NumberOfPhysicalCPU = 0;
150147
std::string buffer;
151148

@@ -163,7 +160,6 @@ unsigned int RetrieveInformationFromCpuInfoFile(){
163160
// and SMT)
164161
size_t pos = buffer.find("processor\t");
165162
while (pos != std::string::npos) {
166-
NumberOfLogicalCPU++;
167163
pos = buffer.find("processor\t", pos + 1);
168164
}
169165

test/mpi/CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ set_property(TEST string_read_mpi PROPERTY DISABLED $<NOT:$<BOOL:${h5py_ok}>>)
7777

7878
get_property(test_names DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY TESTS)
7979

80-
set_property(TEST ${test_names} PROPERTY TIMEOUT 30)
8180
set_property(TEST ${test_names} PROPERTY WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
8281
set_property(TEST ${test_names} PROPERTY RESOURCE_LOCK cpu_mpi)
8382

test/nompi/CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ set_property(TEST deflate_props deflate_read PROPERTY REQUIRED_FILES ${CMAKE_CUR
4343

4444
get_property(test_names DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY TESTS)
4545

46-
set_property(TEST ${test_names} PROPERTY TIMEOUT 30)
4746
set_property(TEST ${test_names} PROPERTY WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
4847

4948
# --- Windows shared DLLs

valgrind.supp

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
{
2+
HDF5-internal-write-close
3+
Memcheck:Param
4+
pwrite64(buf)
5+
fun:pwrite
6+
obj:*/libhdf5*
7+
fun:H5FD_write
8+
fun:H5F__accum_write
9+
fun:H5PB_write
10+
fun:H5F_block_write
11+
fun:H5D__flush_sieve_buf
12+
obj:*/libhdf5*
13+
fun:H5D__flush_real
14+
fun:H5D_close
15+
obj:*/libhdf5*
16+
fun:H5I_dec_ref
17+
}
18+
{
19+
HDF5-write
20+
Memcheck:Param
21+
pwrite64(buf)
22+
fun:pwrite
23+
obj:*/libhdf5*
24+
fun:H5FD_write
25+
fun:H5F__accum_write
26+
fun:H5PB_write
27+
fun:H5F_block_write
28+
obj:*/libhdf5*
29+
obj:*/libhdf5*
30+
obj:*/libhdf5*
31+
obj:*/libhdf5*
32+
fun:H5D__write
33+
fun:H5Dwrite
34+
}
35+
{
36+
HDF5-attributes-close
37+
Memcheck:Param
38+
pwrite64(buf)
39+
fun:pwrite
40+
obj:*/libhdf5*
41+
fun:H5FD_write
42+
fun:H5F__accum_write
43+
fun:H5PB_write
44+
fun:H5F_block_write
45+
fun:H5C__flush_single_entry
46+
fun:H5C_flush_cache
47+
fun:H5AC_flush
48+
obj:*/libhdf5*
49+
fun:H5F__dest
50+
fun:H5F_try_close
51+
}
52+
{
53+
HDF5-zlibng
54+
Memcheck:Cond
55+
fun:memmove
56+
obj:*/libz*
57+
obj:*/libz*
58+
fun:deflate
59+
fun:compress2
60+
obj:*/libhdf5*
61+
fun:H5Z_pipeline
62+
obj:*/libhdf5*
63+
obj:*/libhdf5*
64+
fun:H5D__flush_real
65+
fun:H5D_close
66+
obj:*/libhdf5*
67+
}
68+
{
69+
HDF5-zlibng
70+
Memcheck:Value8
71+
fun:memmove
72+
obj:*/libz*
73+
obj:*/libz*
74+
fun:deflate
75+
fun:compress2
76+
obj:*/libhdf5*
77+
fun:H5Z_pipeline
78+
obj:*/libhdf5*
79+
obj:*/libhdf5*
80+
fun:H5D__flush_real
81+
fun:H5D_close
82+
obj:*/libhdf5*
83+
}

0 commit comments

Comments
 (0)