Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mz/fix oom #1766

Merged
merged 2 commits into from
Nov 14, 2024
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
27 changes: 19 additions & 8 deletions scripts/c_api_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,27 +49,38 @@ REPO_ROOT="${CURR_DIR}/.."
TFHE_BUILD_DIR="${REPO_ROOT}/tfhe/build/"
CPU_COUNT="$("${CURR_DIR}"/cpu_count.sh)"



LINKING_CPU_COUNT=4

# On linux
if [[ $(uname) != "Darwin" ]]; then
mem_in_gb="$(free -g | awk '/Mem:/ {print $2}')"

# If there is more than 100GB on the system,
# use all available cores for linking
# Otherwise, only use 4, to avoid OOM when linking
if [ 100 -lt "$mem_in_gb" ]; then
LINKING_CPU_COUNT="$(CPU_COUNT)"
fi
fi

mkdir -p "${TFHE_BUILD_DIR}"

cd "${TFHE_BUILD_DIR}"

cmake .. -DCMAKE_BUILD_TYPE=RELEASE -DCARGO_PROFILE="${CARGO_PROFILE}" -DWITH_FEATURE_GPU="${WITH_FEATURE_GPU}"

make -j "${CPU_COUNT}"
make -j "${LINKING_CPU_COUNT}"

if [[ "${BUILD_ONLY}" == "1" ]]; then
exit 0
fi

nproc_bin=nproc

# macOS detects CPUs differently
if [[ $(uname) == "Darwin" ]]; then
nproc_bin="sysctl -n hw.logicalcpu"
fi

if [ "${WITH_FEATURE_GPU}" == "ON" ]; then
ctest --output-on-failure --test-dir "." --parallel "$(${nproc_bin})" --tests-regex ".*cuda.*"
ctest --output-on-failure --test-dir "." --parallel "${CPU_COUNT}" --tests-regex ".*cuda.*"
else
ctest --output-on-failure --test-dir "." --parallel "$(${nproc_bin})" --exclude-regex ".*cuda.*"
ctest --output-on-failure --test-dir "." --parallel "${CPU_COUNT}" --exclude-regex ".*cuda.*"
fi
9 changes: 1 addition & 8 deletions scripts/shortint-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,7 @@ 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

n_threads_small="$(${nproc_bin})"
n_threads_small="$("${CURR_DIR}"/cpu_count.sh)"
n_threads_big="${n_threads_small}"

# TODO: automate thread selection by measuring host machine ram and loading the key sizes from the
Expand Down
Loading