-
Notifications
You must be signed in to change notification settings - Fork 23
Use static libraries for AITER build #468
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
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,13 +32,58 @@ while [[ $# -gt 0 ]]; do | |
| done | ||
|
|
||
| if [[ -z "${AITER_DIR}" || -z "${AITER_TEST_DIR}" || -z "${GPU_ARCHS_VAL}" ]]; then | ||
| echo "[AITER-PREBUILT] --aiter-dir, --aiter-test-dir, and --gpu-archs are required." >&2 | ||
| echo "[AITER-BUILD] --aiter-dir, --aiter-test-dir, and --gpu-archs are required." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| rm -rf "${AITER_DIR}/aiter/jit/build" | ||
| AITER_LOG_MORE=1 \ | ||
| CK_TILE_FLOAT_TO_BFLOAT16_DEFAULT="${CK_TILE_BF16_DEFAULT}" \ | ||
| GPU_ARCHS="${GPU_ARCHS_VAL}" \ | ||
| python3 "${AITER_TEST_DIR}/compile.py" | ||
| # rm -rf "${AITER_DIR}/aiter/jit/build" | ||
| # AITER_LOG_MORE=1 \ | ||
| # CK_TILE_FLOAT_TO_BFLOAT16_DEFAULT="${CK_TILE_BF16_DEFAULT}" \ | ||
| # GPU_ARCHS="${GPU_ARCHS_VAL}" \ | ||
| # python3 "${AITER_TEST_DIR}/compile.py" | ||
|
|
||
| # Generate static archives from the built object files only if NVTE_AITER_STATIC_LINK=1 | ||
| if [[ "${NVTE_AITER_STATIC_LINK:-1}" -ne 1 ]]; then | ||
| exit 0 | ||
| fi | ||
|
|
||
| # Check for ar and ranlib | ||
| AR_BIN="${AR:-$(command -v ar || true)}" | ||
| RANLIB_BIN="${RANLIB:-$(command -v ranlib || true)}" | ||
| if [[ -z "${AR_BIN}" ]]; then | ||
| echo "[AITER-BUILD] Could not find ar for static archive generation." >&2 | ||
| exit 1 | ||
| fi | ||
| if [[ -z "${RANLIB_BIN}" ]]; then | ||
| echo "[AITER-BUILD] Could not find ranlib for static archive generation." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Create static archives for both forward and backward passes | ||
| for lib in fwd bwd; do | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since it is built and used by us, will it be more efficient to make single lib? |
||
| src_obj_dir="${AITER_DIR}/aiter/jit/build/libmha_${lib}/build" | ||
| out_archive="${AITER_TEST_DIR}/libmha_${lib}.a" | ||
|
|
||
| if [[ ! -d "${src_obj_dir}" ]]; then | ||
| echo "[AITER-BUILD] Missing object directory: ${src_obj_dir}" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| mapfile -d '' obj_files < <(find "${src_obj_dir}" -type f -name '*.o' -print0) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why so complicated approach, just do what build systems do -> call ar cq @file_list |
||
| if [[ ${#obj_files[@]} -eq 0 ]]; then | ||
| echo "[AITER-BUILD] No object files found under ${src_obj_dir}" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| total_objs=${#obj_files[@]} | ||
|
|
||
| rm -f "${out_archive}" | ||
| "${AR_BIN}" q "${out_archive}" "${obj_files[@]}" | ||
|
|
||
| if [[ -n "${RANLIB_BIN}" ]]; then | ||
| "${RANLIB_BIN}" "${out_archive}" | ||
| fi | ||
|
|
||
| echo "[AITER-BUILD] Created static archive: ${out_archive} (${#obj_files[@]} objects)" | ||
| done | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency it should probably also be changed in CMakeLists.txt