Skip to content

Commit

Permalink
Only print NUMA nodes if requested
Browse files Browse the repository at this point in the history
After updating the build system to CMake XDD was outputing the NUMA
domain for each worker thread in the header of the output. This address
that issue by printing that info in the event it is requested through
the `-debug` flag.

Since the `GO_DEBUG_USER1` global debug was never used, it was updated
to be used for init debugging and changed to GO_DEBUG_INIT. So if the
user does `-debug init` they will now see what cpus the worker threads
have been pinned to.

As part of the work, I also reorganized the test directory a bit. I made
a separate debug test directory just to test out this functionality as
it really did not make sense for it to be in the fuctional test cases. I
placed all the common test CMake variables in the CMakeLists.txt and
then just added individual test information in the functional and debug
CMakeLists.txt files.

Fixes #13
Signed-off-by: Brian Atkinson <batkinson@lanl.gov>
  • Loading branch information
bwatkinson authored and MigeljanImeri committed Jul 28, 2023
1 parent 12ecc0b commit d048249
Show file tree
Hide file tree
Showing 26 changed files with 136 additions and 84 deletions.
21 changes: 11 additions & 10 deletions src/base/worker_thread_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,17 @@ xdd_worker_thread_init(worker_data_t *wdp) {
unsigned char *bufp; // Generic Buffer pointer

#if HAVE_CPU_SET_T && HAVE_PTHREAD_ATTR_SETAFFINITY_NP
// BWS Print the cpuset
int i;
cpu_set_t cpuset;
CPU_ZERO(&cpuset);
pthread_getaffinity_np(pthread_self(), sizeof(cpuset), &cpuset);
printf("Thread %ld bound to NUMA node", (long int) pthread_self());
for (i = 0; i< 48; i++)
if (CPU_ISSET(i, &cpuset))
printf(" %d", i);
printf("\n");
if (xgp->global_options & GO_DEBUG_INIT) {
int i;
cpu_set_t cpuset;
CPU_ZERO(&cpuset);
pthread_getaffinity_np(pthread_self(), sizeof(cpuset), &cpuset);
fprintf(stderr, "Thread %ld bound to NUMA node", (long int) pthread_self());
for (i = 0; i < CPU_SETSIZE; i++)
if (CPU_ISSET(i, &cpuset))
fprintf(stderr, " %d", i);
fprintf(stderr, "\n");
}
#endif

// Get the Target Data Struct address as well
Expand Down
6 changes: 3 additions & 3 deletions src/client/parse_func.c
Original file line number Diff line number Diff line change
Expand Up @@ -808,9 +808,9 @@ xddfunc_debug(xdd_plan_t *planp, int32_t argc, char *argv[], uint32_t flags)
(strcmp(argv[1], "TL") == 0) ||
(strcmp(argv[1], "tl") == 0)) {
xgp->global_options |= GO_DEBUG_TIME_LIMIT;
} else if ((strcmp(argv[1], "USER1") == 0) ||
(strcmp(argv[1], "user1") == 0)) {
xgp->global_options |= GO_DEBUG_USER1;
} else if ((strcmp(argv[1], "INIT") == 0) ||
(strcmp(argv[1], "init") == 0)) {
xgp->global_options |= GO_DEBUG_INIT;
} else if ((strcmp(argv[1], "ALL") == 0) ||
(strcmp(argv[1], "all") == 0) ||
(strcmp(argv[1], "a") == 0)) {
Expand Down
5 changes: 3 additions & 2 deletions src/common/xint_global_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@
#define GO_DEBUG_TS 0x0400000000000000ULL /* */
#define GO_DEBUG_THROTTLE 0x0800000000000000ULL /* */
#define GO_DEBUG_TIME_LIMIT 0x1000000000000000ULL /* */
#define GO_DEBUG_USER1 0x2000000000000000ULL /* */
#define GO_DEBUG_INIT 0x2000000000000000ULL /* */
#define GO_DEBUG_RESULTS 0x4000000000000000ULL /* */
#define GO_DEBUG_ALL (GO_DEBUG_IO|GO_DEBUG_E2E|GO_DEBUG_LOCKSTEP|GO_DEBUG_OPEN|GO_DEBUG_TASK|GO_DEBUG_TOT|GO_DEBUG_TS|GO_DEBUG_THROTTLE|GO_DEBUG_USER1|GO_DEBUG_RESULTS)
#define GO_DEBUG_ALL (GO_DEBUG_IO | GO_DEBUG_E2E |GO_DEBUG_LOCKSTEP |GO_DEBUG_OPEN |GO_DEBUG_TASK | \
GO_DEBUG_TOT |GO_DEBUG_TS |GO_DEBUG_THROTTLE |GO_DEBUG_INIT |GO_DEBUG_RESULTS)

struct xdd_global_data {
uint64_t global_options; /* I/O Options valid for all targets */
Expand Down
34 changes: 34 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,35 @@
configure_file(common.sh common.sh)

# original tests depended on xdd being installed
option(TEST_INSTALLED "Use installed xdd for tests" ON)
if (TEST_INSTALLED)
set(XDD_EXEC "$<TARGET_FILE:xdd>")
else()
set(XDD_EXEC "${CMAKE_BINARY_DIR}/bin/xdd")
endif()

# configurable output directory
set(TESTDIR "${CMAKE_BINARY_DIR}/test-dir" CACHE PATH "Where to place test files")
add_custom_target(mk-test-dir ALL
COMMAND "${CMAKE_COMMAND}" -E make_directory "${TESTDIR}")

# not configurable
set(TESTDIR_TESTS "${TESTDIR}/tests")
add_custom_target(mk-test-tests ALL
COMMAND "${CMAKE_COMMAND}" -E make_directory "${TESTDIR_TESTS}"
DEPENDS mk-test-dir)
set(TESTDIR_LOGS "${TESTDIR}/logs")
add_custom_target(mk-test-logs ALL
COMMAND "${CMAKE_COMMAND}" -E make_directory "${TESTDIR_LOGS}"
DEPENDS mk-test-dir)

# generate config file
file(GENERATE
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/test_config"
CONTENT "XDDTEST_XDD_EXE=${XDD_EXEC}
XDDTEST_LOCAL_MOUNT=${TESTDIR}/tests
XDDTEST_OUTPUT_DIR=${TESTDIR}/logs"
)

add_subdirectory(functional)
add_subdirectory(debug)
File renamed without changes.
12 changes: 12 additions & 0 deletions tests/debug/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
set(DEBUG_TESTS
test_xdd_debug_init.sh
)

foreach(TEST ${DEBUG_TESTS})
configure_file("${TEST}" "${TEST}" COPYONLY)
add_test(NAME "${TEST}"
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${TEST}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
set_tests_properties("${TEST}" PROPERTIES LABELS "debug")
set_tests_properties("${TEST}" PROPERTIES SKIP_RETURN_CODE 255)
endforeach()
36 changes: 36 additions & 0 deletions tests/debug/test_xdd_debug_init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash
#
# Debug output test for XDD.
#
# Validate XDD header has worker thread NUMA cpus printed if requested
#
# Description - Just writes out to /dev/null using XDD with -debug INIT and verifies
# that the NUMA cpus are listed if requested through the debug flag
#
# Source the test configuration environment
#
source ../test_config
source ../common.sh

initialize_test

echo "Foobar and I am here motherfucker"

${XDDTEST_XDD_EXE} -op write -reqsize 128 -numreqs 1 -targets 1 /dev/null -verbose -debug INIT \
2>&1 | grep "bound to NUMA node"

if [[ $? -ne 0 ]]; then
# test failed
finalize_test 1
fi

${XDDTEST_XDD_EXE} -op write -reqsize 128 -numreqs 1 -targets 1 /dev/null -verbose \
2>&1 | grep "bound to NUMA node"

if [[ $? -ne 1 ]]; then
# test failed
finalize_test 1
fi

# test passed
finalize_test 0
34 changes: 1 addition & 33 deletions tests/functional/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
configure_file(common.sh common.sh)

set(FUNCTIONAL
test_xdd_createnewfiles2.sh
test_xdd_heartbeat_byte.sh
Expand All @@ -20,40 +18,10 @@ set(FUNCTIONAL
test_xdd_timelimit.sh
)

# original tests depended on xdd being installed
option(TEST_INSTALLED "Use installed xdd for tests" ON)
if (TEST_INSTALLED)
set(XDD_EXEC "$<TARGET_FILE:xdd>")
else()
set(XDD_EXEC "${CMAKE_BINARY_DIR}/bin/xdd")
endif()

# configurable output directory
set(TESTDIR "${CMAKE_BINARY_DIR}/test-dir" CACHE PATH "Where to place test files")
add_custom_target(mk-test-dir ALL
COMMAND "${CMAKE_COMMAND}" -E make_directory "${TESTDIR}")

# not configurable
set(TESTDIR_TESTS "${TESTDIR}/tests")
add_custom_target(mk-test-tests ALL
COMMAND "${CMAKE_COMMAND}" -E make_directory "${TESTDIR_TESTS}"
DEPENDS mk-test-dir)
set(TESTDIR_LOGS "${TESTDIR}/logs")
add_custom_target(mk-test-logs ALL
COMMAND "${CMAKE_COMMAND}" -E make_directory "${TESTDIR_LOGS}"
DEPENDS mk-test-dir)

# generate config file
file(GENERATE
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/test_config"
CONTENT "XDDTEST_XDD_EXE=${XDD_EXEC}
XDDTEST_LOCAL_MOUNT=${TESTDIR}/tests
XDDTEST_OUTPUT_DIR=${TESTDIR}/logs"
)
foreach(TEST ${FUNCTIONAL})
configure_file("${TEST}" "${TEST}" COPYONLY)
add_test(NAME "${TEST}"
COMMAND sh -c "${CMAKE_CURRENT_BINARY_DIR}/${TEST} 2> ${TESTDIR}/logs/${TEST}.log"
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${TEST}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
set_tests_properties("${TEST}" PROPERTIES LABELS "functional")
set_tests_properties("${TEST}" PROPERTIES SKIP_RETURN_CODE 255)
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/test_xdd_createnewfiles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#
# Source the test configuration environment
#
source ./test_config
source ./common.sh
source ../test_config
source ../common.sh


# Create the test location
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/test_xdd_createnewfiles2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#
# Source the test configuration environment
#
source ./test_config
source ./common.sh
source ../test_config
source ../common.sh

initialize_test

Expand Down
4 changes: 2 additions & 2 deletions tests/functional/test_xdd_heartbeat_byte.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#
# Source the test configuration environment
#
source ./test_config
source ./common.sh
source ../test_config
source ../common.sh

# Pre-test set-up

Expand Down
4 changes: 2 additions & 2 deletions tests/functional/test_xdd_heartbeat_elapsed.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
# Description: outputs the elapsed time since the start of run
# Verify heartbeat elapsed time options works
#
source ./test_config
source ./common.sh
source ../test_config
source ../common.sh

# Pre-test set-up
initialize_test
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/test_xdd_heartbeat_lf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#
# Source the test configuration environment
#
source ./test_config
source ./common.sh
source ../test_config
source ../common.sh

# pre-test set-up
initialize_test
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/test_xdd_heartbeat_output.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
# Verify -hb output by checking if specified file exists
#
# Source test environment
source ./test_config
source ./common.sh
source ../test_config
source ../common.sh

# Pre-test set-up
initialize_test
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/test_xdd_heartbeat_target.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
# Verify -tgt by checking if target number displayed matches target number tested
#
# Source test environment
source ./test_config
source ./common.sh
source ../test_config
source ../common.sh

# pre-test set-up
initialize_test
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/test_xdd_heartbeat_tod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
# Validate -hb tod by comparing it to current time
#
# Source test configuration environment
source ./test_config
source ./common.sh
source ../test_config
source ../common.sh

# pre-test set-up
initialize_test
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/test_xdd_lockstep1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#
# Source the test configuration environment
#
source ./test_config
source ./common.sh
source ../test_config
source ../common.sh

# Create the test location
initialize_test
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/test_xdd_lockstep2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#
# Source the test configuration environment
#
source ./test_config
source ./common.sh
source ../test_config
source ../common.sh

# Create the test location
initialize_test
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/test_xdd_passdelay.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#
# Source the test configuration environment
#
source ./test_config
source ./common.sh
source ../test_config
source ../common.sh

# Pre-test set-up
initialize_test
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/test_xdd_pretruncate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#
# Source the test configuration environment
#
source ./test_config
source ./common.sh
source ../test_config
source ../common.sh

# Pre-test create test directory and file
initialize_test
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/test_xdd_reopen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#
# Source the test configuration environment
#
source ./test_config
source ./common.sh
source ../test_config
source ../common.sh

# Skip test on non-Linux platforms
if [ `uname` != "Linux" ]; then
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/test_xdd_runtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#
# Source the test configuration environment
#
source ./test_config
source ./common.sh
source ../test_config
source ../common.sh

# Perform pre-test
initialize_test
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/test_xdd_startdelay.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#
# Source the test configuration environment
#
source ./test_config
source ./common.sh
source ../test_config
source ../common.sh

# Pre-test set-up
initialize_test
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/test_xdd_startoffset.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
# Validate -startoffset by comparing the size of a file starting from block 0 to its size starting from the nth block
#
# Source the test configuration environment
source ./test_config
source ./common.sh
source ../test_config
source ../common.sh

# Pre-test set-up
initialize_test
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/test_xdd_syncwrite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#
# Source the test configuration environment
#
source ./test_config
source ./common.sh
source ../test_config
source ../common.sh

#skip test on non-Linux platforms
if [ `uname` != "Linux" ]; then
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/test_xdd_timelimit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#
# Source the test configuration environment
#
source ./test_config
source ./common.sh
source ../test_config
source ../common.sh

# Perform pre-test
initialize_test
Expand Down

0 comments on commit d048249

Please sign in to comment.