Skip to content
Merged
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
4 changes: 2 additions & 2 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ cd infinibench/hardware/cuda-memory-benchmark
bash build.sh --platform cuda
```

For MetaX, Iluvatar, Hygon, and Moore Threads build and runtime instructions,
see [Hardware Benchmarks](../infinibench/hardware/README.md).
For MetaX, Iluvatar, Hygon, Moore Threads, and Ascend build and runtime
instructions, see [Hardware Benchmarks](../infinibench/hardware/README.md).

**Note**: This requires:
- CUDA toolkit (compatible with your GPU driver)
Expand Down
24 changes: 18 additions & 6 deletions infinibench/hardware/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Hardware Benchmarks

InfiniBench provides one hardware adapter for NVIDIA CUDA and four additional
CUDA-compatible accelerator platforms. Existing CUDA command shapes and metric
names are kept unchanged.
InfiniBench provides one hardware adapter for NVIDIA CUDA and five additional
accelerator platforms. Existing CUDA command shapes, behavior, and metric names
are kept unchanged. Platform-specific tests use distinct metric names.

## Platforms

Expand All @@ -13,6 +13,7 @@ names are kept unchanged.
| Iluvatar CoreX | `corex`, `iluvatar` | `bash build.sh --platform corex` | `cuda-memory-benchmark/build/cuda_perf_suite` |
| Hygon DCU | `hygon` | `bash build.sh --platform hygon` | `cuda-memory-benchmark/build/cuda_perf_suite` |
| Moore Threads | `moore` | `bash build.sh --platform moore` | `cuda-memory-benchmark/build/cuda_perf_suite` |
| Ascend | `ascend`, `npu` | `bash build.sh` | `ascend-memory-benchmark/build/npu_perf_suite` |

Run each build command from its benchmark directory. All binaries use the same
test selectors and common arguments:
Expand Down Expand Up @@ -44,9 +45,13 @@ example, Moore Threads STREAM uses:
}
```

The aliases `nvidia`, `musa`, and `mthreads` are also accepted as explicit
device values. A selected non-CUDA platform is recorded in the result
configuration as `platform`; metric names remain compatible with CUDA results.
The aliases `nvidia`, `musa`, `mthreads`, and `npu` are also accepted as
explicit device values. A selected non-CUDA platform is recorded in the result
configuration as `platform`. Ascend publishes all four STREAM operations: Copy
uses ACL D2D memcpy, Scale uses `aclnnMuls`, and Add/Triad use `aclnnAdd` with
the corresponding scalar. Its ACL D2D memcpy size sweep is published as
`hardware.d2d_memcpy_size_sweep` and does not claim to isolate AI Core memory
levels.

## Device Visibility

Expand All @@ -58,12 +63,14 @@ The selected physical device is renumbered to device 0 inside the process.
| NVIDIA, MetaX, Iluvatar | `CUDA_VISIBLE_DEVICES` |
| Hygon | `HIP_VISIBLE_DEVICES` and `ROCR_VISIBLE_DEVICES` |
| Moore Threads | `MUSA_VISIBLE_DEVICES` |
| Ascend | `ASCEND_RT_VISIBLE_DEVICES` |

For example:

```bash
CUDA_VISIBLE_DEVICES=2 ./build/cuda_perf_suite --stream --device 0
MUSA_VISIBLE_DEVICES=0 ./build/cuda_perf_suite --stream --device 0
ASCEND_RT_VISIBLE_DEVICES=4 ./build/npu_perf_suite --stream --device 0
```

## Container Notes
Expand All @@ -79,3 +86,8 @@ docker run --rm --privileged \

Without this mount, management tools can list DCUs while HIP applications fail
to load `libhsa-runtime64.so` or `libhydmi.so`.

Some Ascend development images can return exit code 137 after the benchmark has
printed its completion message. The adapter intentionally treats every nonzero
exit code as a failure; fix the container lifecycle rather than suppressing that
error in application code.
83 changes: 83 additions & 0 deletions infinibench/hardware/ascend-memory-benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
cmake_minimum_required(VERSION 3.18)
project(NpuPerfSuite VERSION 1.0.0 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()

# Find Ascend CANN Toolkit
if(DEFINED ENV{ASCEND_HOME_PATH})
set(ASCEND_HOME $ENV{ASCEND_HOME_PATH})
elseif(DEFINED ENV{ASCEND_TOOLKIT_HOME})
set(ASCEND_HOME $ENV{ASCEND_TOOLKIT_HOME})
else()
set(ASCEND_HOME "/usr/local/Ascend/ascend-toolkit/latest")
endif()
message(STATUS "ASCEND_HOME: ${ASCEND_HOME}")

# Detect architecture for library path
execute_process(
COMMAND uname -m
OUTPUT_VARIABLE ARCH_TYPE
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(ARCH_TYPE STREQUAL "aarch64")
set(ARCH_DIR "aarch64-linux")
else()
set(ARCH_DIR "x86_64-linux")
endif()

set(ASCEND_INCLUDE_DIR "${ASCEND_HOME}/${ARCH_DIR}/include")
set(ASCEND_LIB_DIR "${ASCEND_HOME}/${ARCH_DIR}/lib64")

# Verify headers exist
find_path(ACL_INCLUDE_DIR NAMES acl/acl.h HINTS ${ASCEND_INCLUDE_DIR})
if(NOT ACL_INCLUDE_DIR)
message(FATAL_ERROR "acl/acl.h not found in ${ASCEND_INCLUDE_DIR}. "
"Set ASCEND_HOME_PATH or ASCEND_TOOLKIT_HOME.")
endif()

# Find Ascend runtime and operator API libraries
find_library(ASCENDCL_LIB ascendcl HINTS ${ASCEND_LIB_DIR})
if(NOT ASCENDCL_LIB)
message(FATAL_ERROR "libascendcl.so not found in ${ASCEND_LIB_DIR}")
endif()

find_library(OPAPI_LIB opapi HINTS ${ASCEND_LIB_DIR})
if(NOT OPAPI_LIB)
message(FATAL_ERROR "libopapi.so not found in ${ASCEND_LIB_DIR}")
endif()

find_library(NNOPBASE_LIB nnopbase HINTS ${ASCEND_LIB_DIR})
if(NOT NNOPBASE_LIB)
message(FATAL_ERROR "libnnopbase.so not found in ${ASCEND_LIB_DIR}")
endif()

add_executable(npu_perf_suite src/main.cc)
target_include_directories(npu_perf_suite PRIVATE
${ACL_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include
)
target_link_libraries(npu_perf_suite
${ASCENDCL_LIB}
${OPAPI_LIB}
${NNOPBASE_LIB}
pthread
)
target_compile_options(npu_perf_suite PRIVATE -Wall -O3)

install(TARGETS npu_perf_suite RUNTIME DESTINATION bin)

message(STATUS "")
message(STATUS "Configuration Summary:")
message(STATUS " Project: ${PROJECT_NAME} v${PROJECT_VERSION}")
message(STATUS " Build: ${CMAKE_BUILD_TYPE}")
message(STATUS " Arch: ${ARCH_DIR}")
message(STATUS " Include: ${ACL_INCLUDE_DIR}")
message(STATUS " ascendcl: ${ASCENDCL_LIB}")
message(STATUS " opapi: ${OPAPI_LIB}")
message(STATUS " nnopbase: ${NNOPBASE_LIB}")
message(STATUS "")
68 changes: 68 additions & 0 deletions infinibench/hardware/ascend-memory-benchmark/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/bin/bash
set -e

RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'

echo "=========================================="
echo " NPU Performance Suite - Build Script"
echo "=========================================="
echo ""

# Detect CANN installation
if [ -z "${ASCEND_HOME_PATH}" ] && [ -z "${ASCEND_TOOLKIT_HOME}" ]; then
# Try common locations
for dir in /usr/local/Ascend/ascend-toolkit/latest \
/usr/local/Ascend/ascend-toolkit/latest/*/ascend-toolkit/latest; do
if [ -d "$dir" ]; then
export ASCEND_HOME_PATH="$dir"
break
fi
done
if [ -z "${ASCEND_HOME_PATH}" ]; then
echo -e "${RED}ERROR: CANN toolkit not found.${NC}"
echo "Set ASCEND_HOME_PATH or ASCEND_TOOLKIT_HOME environment variable."
echo "Example: export ASCEND_TOOLKIT_HOME=/usr/local/Ascend/ascend-toolkit/latest"
exit 1
fi
fi

# Check for g++
if ! command -v g++ &> /dev/null; then
echo -e "${RED}ERROR: g++ not found.${NC}"
exit 1
fi

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BUILD_DIR="${SCRIPT_DIR}/build"

echo -e "${YELLOW}Creating build directory...${NC}"
mkdir -p "${BUILD_DIR}"
cd "${BUILD_DIR}"

echo -e "${YELLOW}Configuring with CMake...${NC}"
cmake .. -DCMAKE_BUILD_TYPE=Release

echo -e "${YELLOW}Building...${NC}"
make -j$(nproc)

if [ $? -eq 0 ]; then
echo ""
echo -e "${GREEN}Build succeeded!${NC}"
echo ""
echo "Executable: ${BUILD_DIR}/npu_perf_suite"
echo ""
echo "Usage:"
echo " ${BUILD_DIR}/npu_perf_suite --all"
echo " ${BUILD_DIR}/npu_perf_suite --memory"
echo " ${BUILD_DIR}/npu_perf_suite --stream"
echo " ${BUILD_DIR}/npu_perf_suite --cache"
echo ""
else
echo ""
echo -e "${RED}Build failed!${NC}"
echo "Please check the error messages above."
exit 1
fi
Loading
Loading