mirror of
https://github.com/zama-ai/tfhe-rs.git
synced 2026-01-06 21:34:05 -05:00
chore(ci): add a cpu count script to avoid crashing on macOS on make -j
This commit is contained in:
5
Makefile
5
Makefile
@@ -3,6 +3,7 @@ OS:=$(shell uname)
|
||||
RS_CHECK_TOOLCHAIN:=$(shell cat toolchain.txt | tr -d '\n')
|
||||
CARGO_RS_CHECK_TOOLCHAIN:=+$(RS_CHECK_TOOLCHAIN)
|
||||
TARGET_ARCH_FEATURE:=$(shell ./scripts/get_arch_feature.sh)
|
||||
CPU_COUNT=$(shell ./scripts/cpu_count.sh)
|
||||
RS_BUILD_TOOLCHAIN:=stable
|
||||
CARGO_RS_BUILD_TOOLCHAIN:=+$(RS_BUILD_TOOLCHAIN)
|
||||
CARGO_PROFILE?=release
|
||||
@@ -436,7 +437,7 @@ test_cuda_backend:
|
||||
mkdir -p "$(TFHECUDA_BUILD)" && \
|
||||
cd "$(TFHECUDA_BUILD)" && \
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DTFHE_CUDA_BACKEND_BUILD_TESTS=ON && \
|
||||
make -j && \
|
||||
make -j "$(CPU_COUNT)" && \
|
||||
make test
|
||||
|
||||
.PHONY: test_gpu # Run the tests of the core_crypto module including experimental on the gpu backend
|
||||
@@ -700,7 +701,7 @@ check_compile_tests_benches_gpu: install_rs_build_toolchain
|
||||
mkdir -p "$(TFHECUDA_BUILD)" && \
|
||||
cd "$(TFHECUDA_BUILD)" && \
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Debug -DTFHE_CUDA_BACKEND_BUILD_TESTS=ON -DTFHE_CUDA_BACKEND_BUILD_BENCHMARKS=ON && \
|
||||
make -j
|
||||
make -j "$(CPU_COUNT)"
|
||||
|
||||
.PHONY: build_nodejs_test_docker # Build a docker image with tools to run nodejs tests for wasm API
|
||||
build_nodejs_test_docker:
|
||||
|
||||
@@ -39,6 +39,7 @@ done
|
||||
CURR_DIR="$(dirname "$0")"
|
||||
REPO_ROOT="${CURR_DIR}/.."
|
||||
TFHE_BUILD_DIR="${REPO_ROOT}/tfhe/build/"
|
||||
CPU_COUNT="$("${CURR_DIR}"/cpu_count.sh)"
|
||||
|
||||
mkdir -p "${TFHE_BUILD_DIR}"
|
||||
|
||||
@@ -46,7 +47,7 @@ cd "${TFHE_BUILD_DIR}"
|
||||
|
||||
cmake .. -DCMAKE_BUILD_TYPE=RELEASE -DCARGO_PROFILE="${CARGO_PROFILE}" -DWITH_FEATURE_GPU="${WITH_FEATURE_GPU}"
|
||||
|
||||
make -j
|
||||
make -j "${CPU_COUNT}"
|
||||
|
||||
if [[ "${BUILD_ONLY}" == "1" ]]; then
|
||||
exit 0
|
||||
|
||||
10
scripts/cpu_count.sh
Executable file
10
scripts/cpu_count.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
nproc_bin=nproc
|
||||
|
||||
# macOS detects CPUs differently
|
||||
if [[ $(uname) == "Darwin" ]]; then
|
||||
nproc_bin="sysctl -n hw.logicalcpu"
|
||||
fi
|
||||
|
||||
${nproc_bin}
|
||||
@@ -86,15 +86,8 @@ fi
|
||||
CURR_DIR="$(dirname "$0")"
|
||||
ARCH_FEATURE="$("${CURR_DIR}/get_arch_feature.sh")"
|
||||
|
||||
nproc_bin=nproc
|
||||
|
||||
# macOS detects CPUs differently
|
||||
if [[ $(uname) == "Darwin" ]]; then
|
||||
nproc_bin="sysctl -n hw.logicalcpu"
|
||||
fi
|
||||
|
||||
# TODO autodetect/have a finer CPU count depending on memory
|
||||
num_cpu_threads="$(${nproc_bin})"
|
||||
num_cpu_threads="$("${CURR_DIR}"/cpu_count.sh)"
|
||||
|
||||
if uname -a | grep "arm64"; then
|
||||
if [[ $(uname) == "Darwin" ]]; then
|
||||
|
||||
Reference in New Issue
Block a user