From 1de595266867fa0aa6470ac29ebee51218a974b1 Mon Sep 17 00:00:00 2001 From: Marco D'Amico Date: Sat, 28 Mar 2026 11:51:39 +0100 Subject: [PATCH 1/2] SIM_LOG_DIR points to "${SCRIPT_DIR:?}"/log rather then /etc/astra-sim which requires sudo priviledges. --- astra-sim-alibabacloud/build.sh | 4 ++-- astra-sim-alibabacloud/build/astra_ns3/build.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/astra-sim-alibabacloud/build.sh b/astra-sim-alibabacloud/build.sh index 5007f3533..75fb2243c 100755 --- a/astra-sim-alibabacloud/build.sh +++ b/astra-sim-alibabacloud/build.sh @@ -3,7 +3,7 @@ SCRIPT_DIR=$(dirname "$(realpath $0)") NS3_BUILD_DIR="${SCRIPT_DIR:?}"/build/astra_ns3 SIMAI_PHY_BUILD_DIR="${SCRIPT_DIR:?}"/build/simai_phy SIMAI_ANALYTICAL_BUILD_DIR="${SCRIPT_DIR:?}"/build/simai_analytical -SIM_LOG_DIR=/etc/astra-sim +SIM_LOG_DIR="${SCRIPT_DIR:?}"/log # Functions function cleanup_build { @@ -71,4 +71,4 @@ case "$1" in printf -- "-c|--compile mode supported ns3/phy/analytical (example:./build.sh -c ns3)\n" printf -- "-l|--clean (example:./build.sh -l ns3)\n" printf -- "-lr|--clean-result mode (example:./build.sh -lr ns3)\n" -esac \ No newline at end of file +esac diff --git a/astra-sim-alibabacloud/build/astra_ns3/build.sh b/astra-sim-alibabacloud/build/astra_ns3/build.sh index a80138123..21482e68a 100755 --- a/astra-sim-alibabacloud/build/astra_ns3/build.sh +++ b/astra-sim-alibabacloud/build/astra_ns3/build.sh @@ -10,7 +10,7 @@ ASTRA_SIM_DIR="${SCRIPT_DIR:?}"/../../astra-sim INPUT_DIR="${SCRIPT_DIR:?}"/../../inputs NS3_DIR="${SCRIPT_DIR:?}"/../../extern/network_backend/ns3-interface NS3_APPLICATION="${NS3_DIR:?}"/simulation/src/applications/ -SIM_LOG_DIR=/etc/astra-sim +SIM_LOG_DIR="${SCRIPT_DIR:?}"/log BUILD_DIR="${SCRIPT_DIR:?}"/build/ RESULT_DIR="${SCRIPT_DIR:?}"/result/ BINARY="${BUILD_DIR}"/gem5.opt @@ -91,4 +91,4 @@ case "$1" in compile;; -h|--help|*) printf "Prints help message";; -esac \ No newline at end of file +esac From bfa9321d6a5f7706a48cc51c038dc23df0aa19b8 Mon Sep 17 00:00:00 2001 From: Marco D'Amico Date: Sun, 31 May 2026 20:45:43 +0200 Subject: [PATCH 2/2] fix(build): use repo-local SIM_LOG_DIR, avoid sudo-required /etc/astra-sim - export SIM_LOG_DIR from top-level build.sh so child scripts inherit it - ns3/build.sh inherits parent value or falls back to ../../log (same dir) - remove undefined BUILD_DIR cd that aborted compile function early - guard LOG_PATH and RESULT_PATH with #ifndef SIM_LOG_DIR; fall back to /etc/astra-sim when env var not set at cmake time - phynet/CMakeLists.txt injects -DSIM_LOG_DIR when env var is present Closes #254 --- .../astra-sim/network_frontend/phynet/CMakeLists.txt | 4 ++++ .../astra-sim/network_frontend/phynet/SimAiMain.cc | 5 ++++- astra-sim-alibabacloud/astra-sim/system/MockNcclLog.h | 5 ++++- astra-sim-alibabacloud/build.sh | 4 ++-- astra-sim-alibabacloud/build/astra_ns3/build.sh | 2 +- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/astra-sim-alibabacloud/astra-sim/network_frontend/phynet/CMakeLists.txt b/astra-sim-alibabacloud/astra-sim/network_frontend/phynet/CMakeLists.txt index f581acdfc..68b4377ac 100644 --- a/astra-sim-alibabacloud/astra-sim/network_frontend/phynet/CMakeLists.txt +++ b/astra-sim-alibabacloud/astra-sim/network_frontend/phynet/CMakeLists.txt @@ -13,6 +13,10 @@ if(use_rdma) add_definitions(-DPHY_RDMA) message("PROJECT_SOURCE_DIR: ${PROJECT_SOURCE_DIR}") endif() + +if(DEFINED ENV{SIM_LOG_DIR}) + add_definitions(-DSIM_LOG_DIR="$ENV{SIM_LOG_DIR}") +endif() set(CMAKE_BUILD_TYPE Debug) add_executable(SimAI_phynet ${SOURCES} ${HEADERS}) diff --git a/astra-sim-alibabacloud/astra-sim/network_frontend/phynet/SimAiMain.cc b/astra-sim-alibabacloud/astra-sim/network_frontend/phynet/SimAiMain.cc index 6641078ac..b94178836 100644 --- a/astra-sim-alibabacloud/astra-sim/network_frontend/phynet/SimAiMain.cc +++ b/astra-sim-alibabacloud/astra-sim/network_frontend/phynet/SimAiMain.cc @@ -30,7 +30,10 @@ #ifdef PHY_RDMA #include "astra-sim/system/SimAiFlowModelRdma.hh" #endif -#define RESULT_PATH "/etc/astra-sim/results/ncclFlowModel_" +#ifndef SIM_LOG_DIR +#define SIM_LOG_DIR "/etc/astra-sim" +#endif +#define RESULT_PATH SIM_LOG_DIR "/results/ncclFlowModel_" using namespace std; diff --git a/astra-sim-alibabacloud/astra-sim/system/MockNcclLog.h b/astra-sim-alibabacloud/astra-sim/system/MockNcclLog.h index 3f08da30e..8217262a1 100644 --- a/astra-sim-alibabacloud/astra-sim/system/MockNcclLog.h +++ b/astra-sim-alibabacloud/astra-sim/system/MockNcclLog.h @@ -26,7 +26,10 @@ #include #include -#define LOG_PATH "/etc/astra-sim/" +#ifndef SIM_LOG_DIR +#define SIM_LOG_DIR "/etc/astra-sim" +#endif +#define LOG_PATH SIM_LOG_DIR "/" enum class NcclLogLevel { DEBUG, INFO, WARNING,ERROR}; diff --git a/astra-sim-alibabacloud/build.sh b/astra-sim-alibabacloud/build.sh index 75fb2243c..88df108c3 100755 --- a/astra-sim-alibabacloud/build.sh +++ b/astra-sim-alibabacloud/build.sh @@ -4,6 +4,7 @@ NS3_BUILD_DIR="${SCRIPT_DIR:?}"/build/astra_ns3 SIMAI_PHY_BUILD_DIR="${SCRIPT_DIR:?}"/build/simai_phy SIMAI_ANALYTICAL_BUILD_DIR="${SCRIPT_DIR:?}"/build/simai_analytical SIM_LOG_DIR="${SCRIPT_DIR:?}"/log +export SIM_LOG_DIR # Functions function cleanup_build { @@ -43,8 +44,7 @@ function compile { mkdir -p "${SIM_LOG_DIR}"/config/ mkdir -p "${SIM_LOG_DIR}"/topo/ mkdir -p "${SIM_LOG_DIR}"/results/ - local option="$1" - cd "${BUILD_DIR}" || exit + local option="$1" case "$option" in "ns3") cd "${NS3_BUILD_DIR}" diff --git a/astra-sim-alibabacloud/build/astra_ns3/build.sh b/astra-sim-alibabacloud/build/astra_ns3/build.sh index 21482e68a..071c9a2b4 100755 --- a/astra-sim-alibabacloud/build/astra_ns3/build.sh +++ b/astra-sim-alibabacloud/build/astra_ns3/build.sh @@ -10,7 +10,7 @@ ASTRA_SIM_DIR="${SCRIPT_DIR:?}"/../../astra-sim INPUT_DIR="${SCRIPT_DIR:?}"/../../inputs NS3_DIR="${SCRIPT_DIR:?}"/../../extern/network_backend/ns3-interface NS3_APPLICATION="${NS3_DIR:?}"/simulation/src/applications/ -SIM_LOG_DIR="${SCRIPT_DIR:?}"/log +SIM_LOG_DIR="${SIM_LOG_DIR:-"${SCRIPT_DIR:?}"/../../log}" BUILD_DIR="${SCRIPT_DIR:?}"/build/ RESULT_DIR="${SCRIPT_DIR:?}"/result/ BINARY="${BUILD_DIR}"/gem5.opt