Skip to content

Commit 6e520bb

Browse files
authored
Merge pull request #1229 from wmdi/test-compiler
Finish implementing `compiler`
2 parents 74c90bf + 0db60db commit 6e520bb

File tree

149 files changed

+3709
-11505
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

149 files changed

+3709
-11505
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
diff --git a/scripts/cmake/doctestAddTests.cmake b/scripts/cmake/doctestAddTests.cmake
2+
index 3b25485..d3ba906 100644
3+
--- a/scripts/cmake/doctestAddTests.cmake
4+
+++ b/scripts/cmake/doctestAddTests.cmake
5+
@@ -56,12 +56,14 @@ foreach(line ${output})
6+
if("${line}" STREQUAL "===============================================================================" OR "${line}" MATCHES [==[^\[doctest\] ]==])
7+
continue()
8+
endif()
9+
- set(test ${line})
10+
+ set(unescaped_test ${line})
11+
+ # use escape commas to handle properly test cases with commas inside the name
12+
+ string(REPLACE "," "\\," escaped_test ${unescaped_test})
13+
set(labels "")
14+
if(${add_labels})
15+
# get test suite that test belongs to
16+
execute_process(
17+
- COMMAND ${TEST_EXECUTOR} "${TEST_EXECUTABLE}" --test-case=${test} --list-test-suites
18+
+ COMMAND ${TEST_EXECUTOR} "${TEST_EXECUTABLE}" --test-case=${escaped_test} --list-test-suites
19+
OUTPUT_VARIABLE labeloutput
20+
RESULT_VARIABLE labelresult
21+
WORKING_DIRECTORY "${TEST_WORKING_DIR}"
22+
@@ -85,24 +87,22 @@ foreach(line ${output})
23+
24+
if(NOT "${junit_output_dir}" STREQUAL "")
25+
# turn testname into a valid filename by replacing all special characters with "-"
26+
- string(REGEX REPLACE "[/\\:\"|<>]" "-" test_filename "${test}")
27+
+ string(REGEX REPLACE "[/\\:\"|<>]" "-" test_filename "${unescaped_test}")
28+
set(TEST_JUNIT_OUTPUT_PARAM "--reporters=junit" "--out=${junit_output_dir}/${prefix}${test_filename}${suffix}.xml")
29+
else()
30+
unset(TEST_JUNIT_OUTPUT_PARAM)
31+
endif()
32+
- # use escape commas to handle properly test cases with commas inside the name
33+
- string(REPLACE "," "\\," test_name ${test})
34+
# ...and add to script
35+
add_command(add_test
36+
- "${prefix}${test}${suffix}"
37+
+ "${prefix}${unescaped_test}${suffix}"
38+
${TEST_EXECUTOR}
39+
"${TEST_EXECUTABLE}"
40+
- "--test-case=${test_name}"
41+
+ "--test-case=${escaped_test}"
42+
"${TEST_JUNIT_OUTPUT_PARAM}"
43+
${extra_args}
44+
)
45+
add_command(set_tests_properties
46+
- "${prefix}${test}${suffix}"
47+
+ "${prefix}${unescaped_test}${suffix}"
48+
PROPERTIES
49+
WORKING_DIRECTORY "${TEST_WORKING_DIR}"
50+
${properties}

.flake/pkgs/tokenizers-cpp.nix

Lines changed: 0 additions & 43 deletions
This file was deleted.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#! /usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
DIR="$(realpath -- "$(dirname "${BASH_SOURCE[0]}")")"
6+
REPO="$(realpath -- "$DIR/../../../")"
7+
8+
cd "$REPO/build-ci"
9+
make -j $(( $(nproc) < 2 ? 1 : $(nproc)-1 )) "$@"
Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,21 @@ REPO="$(realpath -- "$DIR/../../../")"
88

99
export FF_GPU_BACKEND="cuda"
1010
export FF_CUDA_ARCH=70
11-
cd "$REPO"
12-
mkdir build
13-
cd build
11+
12+
if [[ -d "$REPO/build-ci" ]]; then
13+
rm -rf "$REPO/build-ci"
14+
fi
15+
mkdir "$REPO/build-ci"
16+
cd "$REPO/build-ci"
1417
#if [[ "${FF_GPU_BACKEND}" == "cuda" ]]; then
1518
# export FF_BUILD_ALL_EXAMPLES=ON
1619
# export FF_BUILD_UNIT_TESTS=ON
1720
#fi
21+
IFS=" " read -r -a FLAGS <<< "$CMAKE_FLAGS"
1822
../config/config.linux \
19-
-DCMAKE_CXX_COMPILER="clang++" \
20-
-DCMAKE_C_COMPILER="clang" \
2123
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
2224
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
2325
-DCMAKE_CUDA_COMPILER_LAUNCHER=ccache \
24-
-DFF_USE_EXTERNAL_LEGION=ON \
25-
-DFF_USE_EXTERNAL_JSON=ON \
26-
-DFF_USE_EXTERNAL_FMT=ON \
27-
-DFF_USE_EXTERNAL_SPDLOG=ON
26+
"${FLAGS[@]}"
2827

2928
# vim: set tabstop=2 shiftwidth=2 expandtab:
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#! /usr/bin/env bash
2+
3+
set -euo pipefail
4+
set -x
5+
6+
DIR="$(realpath -- "$(dirname "${BASH_SOURCE[0]}")")"
7+
REPO="$(realpath -- "$DIR/../../../")"
8+
9+
TEST_LIBS=("${@/%/-tests}")
10+
REGEX="^$(IFS='|'; echo "${TEST_LIBS[*]}")\$"
11+
12+
cd "$REPO/build-ci"
13+
make -j $(( $(nproc) < 2 ? 1 : $(nproc)-1 )) "${TEST_LIBS[@]}"
14+
ctest --progress --output-on-failure -L "$REGEX"

.github/workflows/per-lib-check.yml

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ jobs:
2020
with:
2121
submodules: recursive
2222

23+
- name: Add helpers directory to path
24+
run: echo "${PWD}/.github/workflows/helpers" >> $GITHUB_PATH
25+
2326
- name: Install nix
2427
uses: cachix/install-nix-action@v25
2528
with:
@@ -51,24 +54,40 @@ jobs:
5154

5255
- name: Run cmake
5356
run: |
54-
.github/workflows/helpers/build_${{ matrix.gpu_backend }}.sh
57+
cmake_${{ matrix.gpu_backend }}.sh
5558
5659
- name: Build utils
5760
run: |
58-
cd build
59-
make -j $(( $(nproc) < 2 ? 1 : $(nproc)-1 )) utils
61+
build_libs.sh utils
6062
6163
- name: Build op-attrs
6264
run: |
63-
cd build
64-
make -j $(( $(nproc) < 2 ? 1 : $(nproc)-1 )) op-attrs
65+
build_libs.sh op-attrs
6566
6667
- name: Build pcg
6768
run: |
68-
cd build
69-
make -j $(( $(nproc) < 2 ? 1 : $(nproc)-1 )) pcg
69+
build_libs.sh pcg
7070
7171
- name: Build kernels
7272
run: |
73-
cd build
74-
make -j $(( $(nproc) < 2 ? 1 : $(nproc)-1 )) kernels
73+
build_libs.sh kernels
74+
75+
- name: Build substitutions
76+
run: |
77+
build_libs.sh substitutions
78+
79+
- name: Build compiler
80+
run: |
81+
build_libs.sh compiler
82+
83+
- name: Test utils
84+
run: |
85+
test_libs.sh utils
86+
87+
- name: Test substitutions
88+
run: |
89+
test_libs.sh substitutions
90+
91+
- name: Test compiler
92+
run: |
93+
test_libs.sh compiler

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ include(nccl)
8484
include(json)
8585
include(expected)
8686
include(spdlog)
87-
include(doctest)
87+
include(doctestlib) # named doctestlib to avoid a name collision with doctest.cmake in rapidcheck
8888
include(visit_struct)
8989
include(CTest)
9090
include(fmt)

cmake/doctest.cmake

Lines changed: 0 additions & 9 deletions
This file was deleted.

cmake/doctestlib.cmake

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
include(aliasing)
2+
3+
if (FF_USE_EXTERNAL_DOCTEST)
4+
find_package(doctest REQUIRED)
5+
include(doctest) # import doctest_discover_tests
6+
else()
7+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/deps/doctest)
8+
include(${CMAKE_CURRENT_SOURCE_DIR}/deps/doctest/scripts/cmake/doctest.cmake)
9+
endif()
10+
11+
alias_library(doctest doctest::doctest)

cmake/flexflow-utils.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ function(ff_add_test_executable)
118118
${FF_TEST_EXEC_NAME}
119119
${FF_TEST_EXEC_DEPS})
120120

121+
target_compile_definitions(${FF_TEST_EXEC_NAME} PRIVATE FF_TEST_SUITE="${FF_TEST_EXEC_NAME}")
122+
121123
define_ff_vars(${FF_TEST_EXEC_NAME})
122124
ff_set_cxx_properties(${FF_TEST_EXEC_NAME})
123-
doctest_discover_tests(${FF_TEST_EXEC_NAME})
125+
doctest_discover_tests(${FF_TEST_EXEC_NAME} ADD_LABELS 1)
124126
endfunction()

0 commit comments

Comments
 (0)