Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@
astra-sim-alibabacloud/build/simai_analytical/build/
astra-sim-alibabacloud/build/astra_ns3/build/
astra-sim-alibabacloud/extern/
astra-sim-alibabacloud/inputs/config/
!astra-sim-alibabacloud/inputs/config/SimAI.conf
bin/
results/
test/log/
*.log
.cur*
.DS_Store

**/build
**/cmake-cache
!astra-sim-alibabacloud/build
76 changes: 76 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
cmake_minimum_required(VERSION 3.15)

project(SimAI LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

add_compile_options(-Wall -g)

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.3)
message(FATAL_ERROR
"g++ (GNU) version should be greater than 5.3, but found ${CMAKE_CXX_COMPILER_VERSION}")
endif()
endif()

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Default build type" FORCE)
endif()

set(NS3_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ns-3-alibabacloud/simulation")
set(ASTRA_SIM_DIR "${CMAKE_CURRENT_SOURCE_DIR}/astra-sim-alibabacloud/astra-sim")
set(RESULT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/results")

file(MAKE_DIRECTORY "${RESULT_DIR}")

option(SYS_ASSERTS "Enable assert() in all profile with -UNDEBUG" OFF)

set(SIMAI_MODE "analytical" CACHE STRING "SimAI build mode")
set_property(CACHE SIMAI_MODE PROPERTY STRINGS analytical ns3 phy)

set(_valid_simai_modes analytical ns3 phy)
list(FIND _valid_simai_modes "${SIMAI_MODE}" _simai_mode_index)
if(_simai_mode_index EQUAL -1)
message(FATAL_ERROR
"Invalid SIMAI_MODE='${SIMAI_MODE}'. Expected one of: analytical, ns3, phy")
endif()

if(SYS_ASSERTS)
add_compile_options(-UNDEBUG)
message(STATUS "Asserts enabled for all profiles.")
endif()

if(SIMAI_MODE STREQUAL "ns3")
add_subdirectory(
"${CMAKE_CURRENT_SOURCE_DIR}/astra-sim-alibabacloud/build/astra_ns3"
)
set(target_name "scratch_AstraSimNetwork")
set(symlink_name "SimAI_simulator")
elseif(SIMAI_MODE STREQUAL "analytical")
add_subdirectory(
"${CMAKE_CURRENT_SOURCE_DIR}/astra-sim-alibabacloud/build/simai_analytical"
)
set(target_name "SimAI_analytical")
set(symlink_name "SimAI_analytical")
elseif(SIMAI_MODE STREQUAL "phy")
set(USE_RDMA TRUE)
add_subdirectory(
"${CMAKE_CURRENT_SOURCE_DIR}/astra-sim-alibabacloud/build/simai_phy"
)
set(target_name "SimAI_phynet")
set(symlink_name "SimAI_phynet")
else()
message(FATAL_ERROR "Unknown SIMAI_MODE=${SIMAI_MODE}")
endif()

# Link binaries
add_custom_target(create_symlink ALL
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_SOURCE_DIR}/bin"
COMMAND ${CMAKE_COMMAND} -E create_symlink
"$<TARGET_FILE:${target_name}>"
"${CMAKE_SOURCE_DIR}/bin/${symlink_name}"
DEPENDS ${target}
COMMENT "Creating ${symlink_name} symlink..."
)
86 changes: 49 additions & 37 deletions astra-sim-alibabacloud/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,40 +1,52 @@
set(use_rdma ${USE_RDMA})
set(use_analytical ${USE_ANALYTICAL})
file(GLOB astra_SRC
"${PROJECT_SOURCE_DIR}/../../astra-sim/system/collective/*.cc"
"${PROJECT_SOURCE_DIR}/../../astra-sim/system/fast-backend/*.cc"
"${PROJECT_SOURCE_DIR}/../../astra-sim/system/memory/*.cc"
"${PROJECT_SOURCE_DIR}/../../astra-sim/system/scheduling/*.cc"
"${PROJECT_SOURCE_DIR}/../../astra-sim/system/topology/*.cc"
"${PROJECT_SOURCE_DIR}/../../astra-sim/system/*.cc"
"${PROJECT_SOURCE_DIR}/../../astra-sim/system/*.cc"
"${PROJECT_SOURCE_DIR}/../../astra-sim/workload/*.cc"
)
file(GLOB HEADERS
"${PROJECT_SOURCE_DIR}/../../astra-sim/system/collective/*.hh"
"${PROJECT_SOURCE_DIR}/../../astra-sim/system/fast-backend/*.hh"
"${PROJECT_SOURCE_DIR}/../../astra-sim/system/memory/*.hh"
"${PROJECT_SOURCE_DIR}/../../astra-sim/system/scheduling/*.hh"
"${PROJECT_SOURCE_DIR}/../../astra-sim/system/topology/*.hh"
"${PROJECT_SOURCE_DIR}/../../astra-sim/system/*.hh"
"${PROJECT_SOURCE_DIR}/../../astra-sim/system/*.hh"
"${PROJECT_SOURCE_DIR}/../../astra-sim/workload/*.hh"
cmake_minimum_required(VERSION 3.15)

file(GLOB ASTRA_SIM_SOURCES CONFIGURE_DEPENDS
"${CMAKE_CURRENT_SOURCE_DIR}/astra-sim/system/collective/*.cc"
"${CMAKE_CURRENT_SOURCE_DIR}/astra-sim/system/fast-backend/*.cc"
"${CMAKE_CURRENT_SOURCE_DIR}/astra-sim/system/memory/*.cc"
"${CMAKE_CURRENT_SOURCE_DIR}/astra-sim/system/scheduling/*.cc"
"${CMAKE_CURRENT_SOURCE_DIR}/astra-sim/system/topology/*.cc"
"${CMAKE_CURRENT_SOURCE_DIR}/astra-sim/system/*.cc"
"${CMAKE_CURRENT_SOURCE_DIR}/astra-sim/workload/*.cc"
)

file(GLOB ASTRA_SIM_HEADERS CONFIGURE_DEPENDS
"${CMAKE_CURRENT_SOURCE_DIR}/astra-sim/system/collective/*.hh"
"${CMAKE_CURRENT_SOURCE_DIR}/astra-sim/system/collective/*.h"
"${CMAKE_CURRENT_SOURCE_DIR}/astra-sim/system/fast-backend/*.hh"
"${CMAKE_CURRENT_SOURCE_DIR}/astra-sim/system/fast-backend/*.h"
"${CMAKE_CURRENT_SOURCE_DIR}/astra-sim/system/memory/*.hh"
"${CMAKE_CURRENT_SOURCE_DIR}/astra-sim/system/memory/*.h"
"${CMAKE_CURRENT_SOURCE_DIR}/astra-sim/system/scheduling/*.hh"
"${CMAKE_CURRENT_SOURCE_DIR}/astra-sim/system/scheduling/*.h"
"${CMAKE_CURRENT_SOURCE_DIR}/astra-sim/system/topology/*.hh"
"${CMAKE_CURRENT_SOURCE_DIR}/astra-sim/system/topology/*.h"
"${CMAKE_CURRENT_SOURCE_DIR}/astra-sim/system/*.hh"
"${CMAKE_CURRENT_SOURCE_DIR}/astra-sim/system/*.h"
"${CMAKE_CURRENT_SOURCE_DIR}/astra-sim/workload/*.hh"
"${CMAKE_CURRENT_SOURCE_DIR}/astra-sim/workload/*.h"
)
if(use_rdma)
add_definitions(-DPHY_RDMA)
include_directories("$ENV{MPI_INCLUDE_PATH}")
add_definitions(-DPHY_MTP)
set(CMAKE_BUILD_TYPE Debug)
elseif(use_analytical)
list(FILTER HEADERS EXCLUDE REGEX ".*SimAiFlowModelRdma.hh")
list(FILTER astra_SRC EXCLUDE REGEX ".*SimAiFlowModelRdma.cc")
list(FILTER HEADERS EXCLUDE REGEX "${PROJECT_SOURCE_DIR}/../../astra-sim/system/BootStrapnet.hh")
list(FILTER astra_SRC EXCLUDE REGEX "${PROJECT_SOURCE_DIR}/../../astra-sim/system/BootStrapnet.cc")
list(FILTER HEADERS EXCLUDE REGEX "${PROJECT_SOURCE_DIR}/../../astra-sim/system/PhyMultiThread.hh")
list(FILTER astra_SRC EXCLUDE REGEX "${PROJECT_SOURCE_DIR}/../../astra-sim/system/PhyMultiThread.cc")
add_definitions(-DANALYTI)

if(SIMAI_MODE STREQUAL "analytical")
list(FILTER ASTRA_SIM_HEADERS EXCLUDE REGEX ".*SimAiFlowModelRdma\\.hh$")
list(FILTER ASTRA_SIM_SOURCES EXCLUDE REGEX ".*SimAiFlowModelRdma\\.cc$")
list(FILTER ASTRA_SIM_HEADERS EXCLUDE REGEX ".*BootStrapnet\\.hh$")
list(FILTER ASTRA_SIM_SOURCES EXCLUDE REGEX ".*BootStrapnet\\.cc$")
list(FILTER ASTRA_SIM_HEADERS EXCLUDE REGEX ".*PhyMultiThread\\.hh$")
list(FILTER ASTRA_SIM_SOURCES EXCLUDE REGEX ".*PhyMultiThread\\.cc$")
endif()
include_directories("${PROJECT_SOURCE_DIR}/../../")
add_library(AstraSim ${astra_SRC})
set_property(TARGET AstraSim PROPERTY CXX_STANDARD 11)

add_library(AstraSim ${ASTRA_SIM_SOURCES} ${ASTRA_SIM_HEADERS})
target_compile_features(AstraSim PUBLIC cxx_std_17)
target_include_directories(AstraSim PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")

if(USE_RDMA)
target_compile_definitions(AstraSim PRIVATE PHY_RDMA PHY_MTP)

find_package(MPI REQUIRED)
target_link_libraries(AstraSim PUBLIC MPI::MPI_CXX)
endif()

if(SIMAI_MODE STREQUAL "analytical")
target_compile_definitions(AstraSim PRIVATE ANALYTI)
endif()
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
# CMake requirement
cmake_minimum_required(VERSION 3.15)

# 项目名称和设置
project(SimAI_analytical)

# 查找源文件
file(GLOB SOURCES "*.cc") # 会查找当前目录下的所有 .cpp 文件
file(GLOB HEADERS "*.h") # 会查找当前目录下的所有 .h 文件
include_directories("${PROJECT_SOURCE_DIR}/../../../")

file(GLOB SOURCES CONFIGURE_DEPENDS "*.cc")
file(GLOB HEADERS CONFIGURE_DEPENDS "*.hh" "*.h")

# 设置可执行文件
add_executable(SimAI_analytical ${SOURCES} ${HEADERS})

# 链接库
target_link_libraries(SimAI_analytical AstraSim) # 替换为实际需要链接的库名
target_include_directories(SimAI_analytical PRIVATE "${ASTRA_SIM_DIR}")
target_link_libraries(SimAI_analytical PRIVATE AstraSim)
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
function(ns3_export_file src dst)
get_filename_component(dst_dir "${dst}" DIRECTORY)
file(MAKE_DIRECTORY "${dst_dir}")

get_filename_component(dst_abs "${dst}" ABSOLUTE)

if(EXISTS "${dst}" OR IS_SYMLINK "${dst_abs}")
file(REMOVE "${dst}")
endif()

if(NS3_USE_RELATIVE_PATHS_SYMLINKS)
file(RELATIVE_PATH src_path "${dst_dir}" "${src}")
file(TO_CMAKE_PATH "${src_path}" src_path)
else()
set(src_path "${src}")
endif()

if(NS3_EXPORT_HEADERS_AS_STUBS)
if("${src_path}" MATCHES "\\.(h|hh)$")
file(GENERATE OUTPUT "${dst}" CONTENT "#include \"${src_path}\"\n")
else()
configure_file("${src}" "${dst}" COPYONLY)
endif()
else()
file(CREATE_LINK "${src_path}" "${dst}" SYMBOLIC)
endif()
endfunction()

file(GLOB_RECURSE ASTRA_SIM_FILES CONFIGURE_DEPENDS
"${ASTRA_SIM_DIR}/*.cc"
"${ASTRA_SIM_DIR}/*.hh"
"${ASTRA_SIM_DIR}/*.h"
)
list(FILTER ASTRA_SIM_FILES EXCLUDE REGEX "/network_frontend/")
list(FILTER ASTRA_SIM_FILES EXCLUDE REGEX "/build/")

foreach(src_file IN LISTS ASTRA_SIM_FILES)
string(REPLACE "${ASTRA_SIM_DIR}/" "astra-sim/" relative_path "${src_file}")
ns3_export_file("${src_file}" "${NS3_SRC_DIR}/src/applications/${relative_path}")
endforeach()

file(GLOB NS3_FRONTEND_FILES CONFIGURE_DEPENDS
"${ASTRA_SIM_DIR}/network_frontend/ns3/*.cc"
"${ASTRA_SIM_DIR}/network_frontend/ns3/*.hh"
"${ASTRA_SIM_DIR}/network_frontend/ns3/*.h"
)

foreach(src_file IN LISTS NS3_FRONTEND_FILES)
get_filename_component(filename "${src_file}" NAME)
ns3_export_file("${src_file}" "${NS3_SRC_DIR}/scratch/${filename}")
endforeach()

string(TOLOWER "${CMAKE_BUILD_TYPE}" _build_type_lower)
if(_build_type_lower STREQUAL "release")
if(NOT DEFINED NS3_ASSERT)
set(NS3_ASSERT OFF CACHE BOOL "Override NS3_ASSERT" FORCE)
endif()
if(NOT DEFINED NS3_LOG)
set(NS3_LOG OFF CACHE BOOL "Override NS3_LOG" FORCE)
endif()
endif()

if(NOT DEFINED NS3_WARNINGS_AS_ERRORS)
set(NS3_WARNINGS_AS_ERRORS OFF CACHE BOOL "Override NS3_WARNINGS_AS_ERRORS" FORCE)
endif()

if(NOT DEFINED NS3_MTP)
set(NS3_MTP ON CACHE BOOL "Override NS3_MTP" FORCE)
endif()

if(DEFINED NS3_NATIVE_OPTIMIZATIONS AND NS3_NATIVE_OPTIMIZATIONS)
add_compile_options(-march=native)
endif()

get_filename_component(NS3_COPIED_PREFIX_1 "${NS3_SRC_DIR}/src/applications/astra-sim" REALPATH)
get_filename_component(NS3_ORIGINAL_PREFIX_1 "${ASTRA_SIM_DIR}" REALPATH)
get_filename_component(NS3_COPIED_PREFIX_2 "${NS3_SRC_DIR}/scratch" REALPATH)
get_filename_component(NS3_ORIGINAL_PREFIX_2 "${ASTRA_SIM_DIR}/network_frontend/ns3" REALPATH)

add_compile_options(
-ffile-prefix-map=${NS3_COPIED_PREFIX_1}=${NS3_ORIGINAL_PREFIX_1}
-ffile-prefix-map=${NS3_COPIED_PREFIX_2}=${NS3_ORIGINAL_PREFIX_2}
)

add_subdirectory("${NS3_SRC_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/ns3")
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
# CMake requirement
cmake_minimum_required(VERSION 3.15)


project(SimAI_phynet)
file(GLOB SOURCES "*.cc")
file(GLOB HEADERS "*.h")
include_directories("${PROJECT_SOURCE_DIR}/../../../")
include_directories("$ENV{MPI_INCLUDE_PATH}")

set(use_rdma ${USE_RDMA})
if(use_rdma)
add_definitions(-DPHY_RDMA)
message("PROJECT_SOURCE_DIR: ${PROJECT_SOURCE_DIR}")
endif()
set(CMAKE_BUILD_TYPE Debug)
add_executable(SimAI_phynet ${SOURCES} ${HEADERS})
file(GLOB SOURCES CONFIGURE_DEPENDS "*.cc")
file(GLOB HEADERS CONFIGURE_DEPENDS "*.hh" "*.h")

add_executable(SimAI_phynet ${SOURCES} ${HEADERS})
target_include_directories(SimAI_phynet PRIVATE "${ASTRA_SIM_DIR}")
target_link_options(SimAI_phynet PRIVATE "-static-libstdc++")
target_compile_definitions(SimAI_phynet PRIVATE PHY_MTP)

if(use_rdma)
target_link_libraries(SimAI_phynet AstraSim mpi ibverbs pthread)
if(USE_RDMA)
target_compile_definitions(SimAI_phynet PRIVATE PHY_RDMA)
target_link_libraries(SimAI_phynet PRIVATE AstraSim ibverbs pthread)
else()
target_link_libraries(SimAI_phynet PRIVATE AstraSim)
endif()
18 changes: 3 additions & 15 deletions astra-sim-alibabacloud/build/astra_ns3/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
# CMake requirement
cmake_minimum_required(VERSION 3.15)

# C++ requirement
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
add_definitions("-Wall -g")
SET(CMAKE_BUILD_TYPE "Debug")

# Compiler requirement
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.3)
message(FATAL_ERROR "g++ (GNU) version should be greater than 5.3, but found ${CMAKE_CXX_COMPILER_VERSION}")
endif()
endif()


# Setup project
project(AstraSimNetwork)

# Compile AnalyticalBackend binary
add_subdirectory ("${PROJECT_SOURCE_DIR}/../../astra-sim/network_frontend/ns3" simai_ns3)
2 changes: 1 addition & 1 deletion astra-sim-alibabacloud/build/astra_ns3/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ case "$1" in
debug;;
-c|--compile)
setup
compile_astrasim
#compile_astrasim
compile;;
-r|--run)
setup
Expand Down
13 changes: 0 additions & 13 deletions astra-sim-alibabacloud/build/simai_analytical/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
# CMake requirement
cmake_minimum_required(VERSION 3.15)

# C++ requirement
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)

# Compiler requirement
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.3)
message(FATAL_ERROR "g++ (GNU) version should be greater than 5.3, but found ${CMAKE_CXX_COMPILER_VERSION}")
endif()
endif()


# Setup project
project (AstraSim_Analytical)

Expand Down
2 changes: 1 addition & 1 deletion astra-sim-alibabacloud/build/simai_analytical/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function setup {

function compile {
cd "${BUILD_DIR}" || exit
cmake -DUSE_ANALYTICAL=TRUE ..
cmake -DSIMAI_MODE="analytical" ..
make
}

Expand Down
7 changes: 0 additions & 7 deletions astra-sim-alibabacloud/build/simai_phy/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
# CMake requirement
cmake_minimum_required(VERSION 3.15)

set(CMAKE_CXX_COMPILER "$ENV{MPI_BIN_PATH}")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MPI_COMPILE_FLAGS} -std=c++11")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${MPI_LINK_FLAGS} -std=c++11")

project (SimAi_Phy)

add_definitions(-DPHY_MTP)
add_subdirectory("${PROJECT_SOURCE_DIR}/../../" AstraSim)

add_subdirectory ("${PROJECT_SOURCE_DIR}/../../astra-sim/network_frontend/phynet" simai_phynet)
Loading