Repository navigation
Aocl 5.3.2 - #57
Closed
rohrayan wants to merge 33 commits into
Closed
Aocl 5.3.2#57rohrayan wants to merge 33 commits into
rohrayan wants to merge 33 commits into
Conversation
- When SOURCE_DATE_EPOCH is set, it contains a unix timestamp to be used in place of the current datetime during builds to allow bit-for-bit reproducible builds to be produced. - Added support for this behavior in the CMake build system as well. See also: https://reproducible-builds.org/docs/source-date-epoch/ https://reproducible-builds.org/specs/source-date-epoch/ Co-authored-by: Luna <[email protected]> Co-authored-by: KR, Chandrashekara <[email protected]>
…rnels (flame#334) * optimize edge and non-unit stride path with intrinsics ins/c axpyv kernels - Updated the edge and non-unit stride path in c/saxpy to use intrinsics. - This ensures that the edge and non-unit stride cases maintain numerical consistency with the optimized Zen assembly/intrinsic path. --------- Co-authored-by: harsdave <[email protected]>
…#300) * ZGEMM SUP: Add conjugate support for AVX-512 kernels on Zen4/Zen5/Zen6 - Add CONJA, CONJB and CONJA_CONJB variants to zgemm SUP micro-tiles - Enable SUP path for conjugate cases when both are same type - Unify RRC/CRC storage to use CV kernel variant - Update SUP dispatch to handle conjugate flags correctly Note: CONJ_NO_TRANSPOSE + CONJ_NO_TRANSPOSE and CONJ_TRANSPOSE + CONJ_TRANSPOSE remain unsupported --------- Co-authored-by: harsdave <[email protected]>
* Bitexactness CRC verification and per-test JSON output * Remove redundant BLIS_TEST_SEED random seed utilities The random_seed_utils.h and BLIS_TEST_SEED environment variable are unnecessary since the codebase already ensures deterministic random number generation via RANDOM_POOL_SEED and SRAND_SEED constants hardcoded in testing_helpers.h. * Add CRC support for integer/char computediff and cache env var checks Add CRC calculation and binary output to the gtint_t and char specializations of computediff, matching the pattern used by all other overloads. Char values are widened to gtint_t for safe uint32_t-aligned CRC access. Cache BLIS_ENABLE_CRC and BLIS_ENABLE_BINARY_OUTPUT env var lookups via static const bool in is_crc_enabled() and is_binary_output_enabled(). Guard all CRC/binary blocks in computediff with is_any_verification_enabled() so the common disabled path is a single static bool read with zero allocations. * Address PR review comments and refactor computediff CRC blocks Refactor: Extract duplicated CRC/binary-output blocks from all 8 computediff overloads into verify_vector_data and verify_matrix_data helpers in blis_test_utils namespace. Bug fixes from PR review: add missing includes (cstdlib, utility), enforce MAX_OUTPUT_SIZE_BYTES limit with integer overflow guard, add buffer validation in all CRC generation functions, add default case to FLA_GET_DATATYPE_FACTOR macro, replace deprecated test_case_name() with test_suite_name(), add MAKE_DIRECTORY error checking in CMake, and update copyright years to 2026. * Refactored crc_utils based on review comments. * binary_output_utils.h cleanup. * Address PR review comments: remove unused functions and fix copyright years. Remove unused generate_crc_matrix, generate_crc_matrix_no_nb_diag, generate_crc_matrix_no_nb_diag_with_storage, and calculate_and_print_matrix_crc from crc_utils.h. Remove unused calculate_and_print_matrix_hash from check_error.h. Fix copyright year to 2026 only in crc_utils.h and binary_output_utils.h. Remove (Performance) label from CRC heading in README.md. Co-authored-by: Cursor <[email protected]> * Fix for review comments. * Address review comments: rename verify to collect, consistent void returns, remove filename prefix - Rename verify_vector_data/verify_matrix_data to collect_vector_data/ collect_matrix_data since these functions only collect CRC and binary output data without performing comparison. - Make return types consistent: change calculate_and_print_crc, calculate_and_print_matrix_crc_with_storage, format_and_record_crc, and write_comparison_outputs to return void since return values were never used. - Remove redundant test_output_ prefix from generate_binary_filename to avoid duplication with the blis_test_outputs/ directory. - Remove unused utility include from binary_output_utils.h. - Update README wording from compiled out to disabled. Made-with: Cursor * Fix strict aliasing, use if constexpr, zero-pad CRC hex, separate feature guards - Replace reinterpret_cast<uint32_t*> with memcpy-based read_uint32() helper to avoid strict-aliasing UB on float/double/complex buffers. Produces identical CRC values. - Use if constexpr(CRC_ENABLED) instead of runtime if(!CRC_ENABLED) to prevent CRC template instantiation when ENABLE_CRC is off. - Zero-pad CRC hex output to 8 digits for stable downstream comparison. - Separate ENABLE_CRC and ENABLE_BINARY_OUTPUT preprocessor guards in verification_utils.h so each feature is compiled independently. Made-with: Cursor * Handle write_binary_output return values in write_comparison_outputs Capture the bool return values from write_binary_output and, on failure, log a warning to stdout and record the error as a GTest property. This keeps binary output as a non-fatal diagnostic aid while ensuring return values are explicitly used. Made-with: Cursor --------- Co-authored-by: Anuraj <[email protected]> Co-authored-by: Cursor <[email protected]>
* Resolved memory-access issues in the SGEMM SUP kernels on AVX2 and AVX-512 by correcting instructions that could read invalid addresses in the C matrix. * Removed k=0 kernel gtests for the native SGEMM and DGEMM paths as these tests caused spurious failures for kernels that are not intended to handle this case. * Standardized all instruction macros to lowercase in the Zen4 kernel to improve readability and code consistency. --------- AMD-Internal: CPUPL-8117 Co-authored-by: Rayan <[email protected]>
* Cleanup of disabled tests * Updating ger evt tests to identify the failing cases * Updating sgemv.evt tests to separate known failures and disable those tests * Update threshold in dtpsv * disabling dgemm_kernel tests that fail * disabling sgemm_kernel tests that fail * disabling cgemv_evt tests that fail * disabling cgemv_evt tests that fail * disabling cgemv_evt and zgemv_evt tests that fail * Fixing typo Co-authored-by: Copilot <[email protected]> * Adding comment on dtpsv threshold adjustment * Update gtestsuite/testsuite/level2/ger/cger/evt/cger_evt.cpp Co-authored-by: Copilot <[email protected]> * Update gtestsuite/testsuite/level2/ger/zger/evt/zger_evt.cpp Co-authored-by: Copilot <[email protected]> * Update gtestsuite/testsuite/level2/tpsv/dtpsv/dtpsv_generic.cpp Co-authored-by: Copilot <[email protected]> * Update gtestsuite/testsuite/level2/tpsv/dtpsv/dtpsv_generic.cpp Co-authored-by: Copilot <[email protected]> * Update gtestsuite/testsuite/level2/ger/zger/evt/zger_evt.cpp Co-authored-by: Copilot <[email protected]> * Update gtestsuite/testsuite/level2/ger/cger/evt/cger_evt.cpp Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
Update problem sizes and other parameters for general GEMM and GEMMT tests, and dgemmt EVT tests, with the aim of reducing the runtime and make tests more practical for use in pre-submit CI jobs. AMD-Internal: [CPUPL-7386]
Non-AVX512 variants of ZGEMM tiny code path do not support as many problem sizes and transa/transb options. Skip unsuitable tests based on the return value from from bli_zgemm_tiny call. Also remove unused local variables. AMD-Internal: [CPUPL-7303]
- Replace mul+add with FMA for ddot, daxpy and daxpyf - Using masked operations where possible - Non-unit stride code paths still use scalar loops, but use FMAs for accuracy AMD-Internal: CPUPL-8055 Co-authored-by: Rohan Rayan [email protected]
- For BF16 GEMVM1 fallback path when B matrix is reordered, there wasn't a panel adjustment happening after the kernel execution. - When the input size exceeds the panel boundary this would cause wrong panel access leading to incorrect results. Hence, added the same. [ AMD-Internal : CPUPL-8201 ]
nn, tn, tt, nt, cn, ct, nc, tc. Previously, the error-handling logic only explicitly checked for and rejected cc and hh cases. This patch extends that check to include ch and hc configurations, ensuring they correctly return a failure/fallback instead of proceeding with unsupported kernels. AMD-Internal: [CPUPL-8151] Co-authored-by: harsdave <[email protected]>
Fixing a memory issue in the cgemm zen4 packing kernel In the loop section where the leftover m and k iterations were handled, the load operations (in the k-direction) were missing the mask instructions which has now been added. AMD-Internal: CPUPL-8189 Co-authored-by: Rohan Rayan [email protected]
This PR optimizes the complex scalar vector multiplication kernels by replacing intrinsics with inline assembly and leveraging FMA (Fused Multiply-Add) instructions for improved performance. Changes: - Replaced intrinsic-based implementation with inline assembly - Utilizes `vfmaddsub231ps`, `vfmadd231ss`, and `vfmsub231ss` FMA instructions - Improved instruction scheduling and register usage - Handles both unit-stride (vectorized) and non-unit-stride (scalar) cases - Processes up to 16 complex elements per iteration in the main loop
- Resovles label collision errors across assembly blocks of zgemm sup kernels. AMD-Internal: [CPUPL-8336] Co-authored-by: harsdave <[email protected]>
* Pack B matrix for zgemm conjugate input in SUP path - B matrix is packed for zgemm input where B matrix is conjugate transpose. AMD-Internal: CPUPL-8274 * Pack B matrix for zgemm conjugate input in SUP path - B matrix is packed for zgemm input where B matrix is conjugate transpose. AMD-Internal: CPUPL-8274 --------- Co-authored-by: harsdave <[email protected]>
Changes to fix errors and warnings when using gcc 16.1.0: - Copy changes from 5c2b22d in upstream BLIS to extend disabling of tree-vectorization in affected kernels to gcc 16 and later. - Remove unused variables in bli_packm_blk_var1_md.c and bli_util_unb_var1.c to fix warning messages. Background bp (base pointer) is the %rbp/%ebp register on x86/x86-64. Inline assembly kernels in BLIS use asm volatile blocks where they manually manage registers - including saving and restoring bp themselves to use it as a general-purpose register for holding loop counters or matrix pointers. When GCC's tree-vectorizer (specifically the superword-level parallelism (SLP) pass) runs on a translation unit containing inline asm, it can generate code that itself needs bp as a frame pointer or in the vectorized prologue/epilogue. At that point GCC internally marks bp as unavailable and then, when it tries to compile the inline asm block that also references bp, it throws an error. As a workaround, disabling tree vectorization for the entire file removes the conflict - with no vectorizer-generated code, bp stays free for the inline asm.
Enable Control Flow Guard (CFG) and Control-flow Enforcement Technology
(CET) hardening for Windows clang-cl builds in the CMake build system.
Gated by the ENABLE_SECURITY_FLAGS option (default ON).
Flags:
Compiler: /guard:cf /guard:ehcont
Linker: /GUARD:CF /GUARD:EHCONT /cetcompat
Toolchain gating:
Requires CMAKE_C/CXX_COMPILER_ID == Clang AND
CMAKE_C/CXX_COMPILER_FRONTEND_VARIANT == MSVC.
Native cl.exe and other MSVC-frontend toolchains fall through to a
warning and skip the hardening flags.
Scope of linker flags:
/cetcompat is applied to blis_shared only (not propagated via
INTERFACE from blis_static) to avoid enabling hardware shadow-stack
enforcement on downstream consumer EXEs that include non-CET-clean
paths (e.g. the testsuite's setjmp/longjmp xerbla code on zen4/zen5).
Configuration:
cmake -DENABLE_SECURITY_FLAGS=OFF ... # disable
Files changed:
blis/CMakeLists.txt
When AOCL_TB_UNIFIED_BUILD is set, add BLIS' object files (OBJECT_LIBRARIES, a list of $<TARGET_OBJECTS:...> genexes) to the single libaocl via aocl_tb_add_objects, so BLIS builds as part of the unified AOCL build instead of as a standalone archive.
- bli_nthreads_optimum's per-shape AOCL_DYNAMIC heuristic picks substantially different thread counts across consecutive calls (e.g. 16 for small fringe shapes, 96 for medium shapes), forcing the underlying OpenMP team to repeatedly park and wake the same idle threads. - Bypass the heuristic when either operand is conjugated for the dcomplex GEMM dispatch path (Zen6 / Zen5 / Zen4 and the pre-Zen4 fallback) so n_threads_ideal stays at the application-requested value, which lets the OpenMP team be reused as-is across calls. Non-conjugate ZGEMM continues to go through the existing AOCL_DYNAMIC cascade unchanged. Co-authored-by: harsdave <[email protected]>
* Fix heap corruption in mixed-domain/precision GEMM - In the BLIS_DISABLE_SYSTEM single-threaded stub, bli_pthread_once() ignored the once-control state and unconditionally called init() on every invocation. bli_init_once() (invoked at the top of essentially every public BLIS API entry via bli_rntm_init_from_global() etc.) therefore re-ran bli_init_apis() -> bli_pba_init() -> bli_pool_init() on every call, reallocating each pool's block_ptrs[] array and orphaning any pblk_t already checked out. * Update bli_pthread.c * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <[email protected]> * reset gks_once_init in bli_gks_finalize and run init before marking once-control done --------- Co-authored-by: harsdave <[email protected]> Co-authored-by: Copilot Autofix powered by AI <[email protected]> Co-authored-by: KR, Chandrashekara <[email protected]>
Removed function calls to 6x48, 6x32, 6x16, 6x8, 6x4 fringe kernels. These are now handled in the main kernel directly Introduced new fringe kernels 6x3, 6x2 in the n-direction Removed fringe kernel calls to AVX2 code path Access pattern inside the kernel changed so that the C-matrix stores are along the cache line Various instruction level optimizations These kerels are enabled also on the Zen6 code path Tiny path modified to take these newer kernels on zen5 and zen6 Added Gtests for these new kernels AMD-Internal: CPUPL-8424, SWLCSG-3272 Co-authored-by: Rohan Rayan [email protected]
Added AVX512 new single threaded and multi threaded kernels for all datatypes of GEMV. Replaced all AVX512 GEMV kernels with a one kernel for transpose and one for notranspose. Replaced all kernel dispatchers with single macro based function. Kernels implemented using preprocessor macros. Added AOCL Dynamic logic for all datatypes General code cleanup AMD-Internal: [CPUPL-8735]
GER: Add OpenMP multithreading for Zen4/Zen5 Parallelize GER rank-1 update operation using OpenMP Reuse GEMV single-thread thresholds to ensure consistent cache behavior when multiple L2 APIs operate on similar data Use AOCL_DYNAMIC thread selection for optimal thread count var1: partition work along M dimension (rows) var2: partition work along N dimension (columns) Add DTL performance logging for GER AMD-Internal: [CPUPL-8737]
* cgemm avx512 kernel: support for all conja/conjb in micro-kernel Add the CONJA_CONJB micro-tile variant to the 24x4 micro-kernel so all four (conja, conjb) quadrants are supported. * tiny gemm: dispatch on ISA tier via bli_arch_isa_tier() Replace the raw arch_id switch in bli_dgemm_tiny/bli_zgemm_tiny/ bli_cgemm_tiny with a switch on bli_arch_isa_tier(arch_id) so the Zen->tier mapping lives in one place (new Zen parts only need adding there). The AVX-512 tiny kernels are still compile-time guarded, now with the precise BLIS_KERNELS_ZEN4 macro instead of the BLIS_FAMILY_* list, since the runtime tier check does not guarantee the kernel symbol is linked into the binary. Behavior-neutral. --------- Co-authored-by: harsdave <[email protected]> Co-authored-by: Kiran Varaganti <[email protected]>
Added dynamic blocksizes logic for zen6-dense. AMD-Internal: SWLCSG-4439
- version: 5.3.1 -> 5.3.2 - so_version: 3.1 -> 3.2 - LICENSE, NOTICES: refreshed from AOCL-5.3; LICENSE now reads AOCL-BLIS v5.3.2
Introduce a self-contained, header-only memory allocator that AOCL-BLAS can use as the backend for its tuned for the heavy multithreaded allocate/free. It is opt-in via --enable-aocl-alloc and off by default, so standard builds are unchanged. Design - Per-thread lock-free LIFO free lists (TLS bins) partitioned by size class are the fast path - Per-core shared recycle pools (per-core mutex) give cross-thread reuse and NUMA/core locality. Recommended usage - For best performance, pair --enable-aocl-alloc with --disable-pba-pools. The allocator already recycles memory buffers per thread, so AOCL_BLAS's PBA pool becomes a redundant caching layer on top of it. Disabling it lets those allocations flow through to the allocator's own recycling.
The `omp parallel ... if(n_threads > 1)` clause does not avoid the OpenMP runtime: GCC still emits an unconditional GOMP_parallel() call and only adjusts its num_threads argument, so libgomp's global per-region bookkeeping is entered on every call. When many application threads each issue their own single-threaded GEMM, they serialize there instead of running concurrently. Replace the if-clause with a C-level branch that runs the operation inline, with no OpenMP region at all, when n_threads == 1. This is done in both the conventional (bli_l3_decor_openmp.c) and sup (bli_l3_sup_decor_openmp.c) decorators; the per-thread body is factored into a shared helper so the multi-threaded path is unchanged. Apply the same idea to scalv: bla_scal_amd.c computed the thread count and then unconditionally entered an 'omp parallel num_threads(nt)' region even when nt == 1, unlike its sibling axpyv (bla_axpy_amd.c) which already short-circuits that case. Add an nt == 1 early return to dscal_blis_impl and zdscal_blis_impl so a single-threaded scal invokes the scalv kernel directly. The direct call passes the length as negative, matching the parallel path, to preserve the "don't use SETV when alpha == 0" behavior. Because the single-threaded path no longer enters a parallel region, bli_l3_thread_decorator_thread_check() can no longer assume it runs inside a BLIS-created team. Reading omp_get_num_threads() there would report the size of any enclosing *application* OpenMP team, tripping the thread mismatch path and calling bli_abort() even though BLIS had correctly run with one thread -- which broke the case of each application thread issuing its own single-threaded gemm, on both the dense and sup paths. Return early from the check when n_threads == 1, since the comparison is only meaningful when BLIS forms its own team. The guard lives in the shared callee rather than at the two call sites so that no future inline fast path can reintroduce the abort, and so the orphaned omp barrier on the mismatch path can never bind to an application team. Behavior is unchanged for the other callers (l3_compute, the gemmd addon, the gemmlike sandbox), which always create their own region and for a one-thread team already found n_threads_real == n_threads. Verified numerics against a naive reference for single- and multi-threaded gemm across dense and sup shapes, and for the nt == 1 scal path including alpha == 0. A dgemm issued from inside an application OpenMP team with BLIS set to one thread aborted before the thread-check change and passes after, on both the dense and sup paths. The nesting-disabled case the check exists for -- BLIS requesting several threads but receiving a team of one -- still downgrades gracefully rather than aborting. Co-authored-by: Cursor <[email protected]>
AVX512 transpose kernels use asm code. If blis is complied with int size 32, the cast to 64 bit is not performed before asm region. When this data is loaded as 64 bit to register it results in segfault. To fix this, datatypes have been changed to 64 bit. AMD-Internal:[CPUPL-9020]
bli_packm_init_pack() sized the packed buffer using the source matrix's element size, but the buffer holds elements of the target datatype. In mixed-precision/mixed-domain GEMM (e.g. float input computed in double) the target type is wider, so the buffer was allocated at half the needed size and the packm kernel wrote past its end. Size the buffer from bli_dt_size(dt_tar) instead. The object's elem_size field is left unchanged, since bli_gemm_ker_var2() reads it back to detect mixed precision and route to the generic macro kernel. Co-authored-by: Dave, Harsh <[email protected]> AMD-Internal: [CPUPL-9027]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Release pull request