Commit Graph

3845 Commits

Author SHA1 Message Date
Prabhu, Anantha
77e4d229be Update ai-pr-platform-app.yml 2025-11-07 23:09:59 +05:30
Prabhu, Anantha
25d172b835 AI Coverity Fix - Historical Analysis related changes
Add AI Coverity Fix - Historical Analysis related changes
2025-11-07 23:09:59 +05:30
Tyagi, Shubham
b602b61601 Update ai-pr-platform-app.yml 2025-11-07 23:09:59 +05:30
Tyagi, Shubham
98164e06a6 Update ai-pr-platform-app.yml 2025-11-07 23:09:59 +05:30
Tyagi, Shubham
aebc02e2f3 Update ai-pr-platform-app.yml 2025-11-07 23:09:59 +05:30
Tyagi, Shubham
8c0196fef9 Add ai-pr-platform-app.yml 2025-11-07 23:09:59 +05:30
Smyth, Edward
85bd30ab3b DTL Windows getpid support
Use _getpid in Windows builds so that separate DTL log and trace
files are used for each process, e.g. each MPI rank.

AMD-Internal: [CPUPL-7524]
2025-11-07 17:03:25 +00:00
Varaganti, Kiran
9230c978a1 Fixed Data Race in Native code-path (#251)
```c
_Pragma( "omp parallel num_threads(n_threads)" )
{
    // ... thread work ...

    // Free the current thread's thrinfo_t structure.
    bli_l3_thrinfo_free( rntm_p, thread );  // Line 183
}
// *** MISSING BARRIER HERE! ***

// Check the array_t back into the small block allocator...
bli_sba_checkin_array( array );  // Line 200
```

```c
// DANGEROUS execution timeline:
Thread 0 (chief):
    completes func()
    calls bli_l3_cntl_free()
    calls bli_l3_thrinfo_free() → frees gl_comm ✓
    exits OpenMP parallel region
    calls bli_sba_checkin_array(array) → frees array ✗

Thread 1,2,3 (still executing):
    still in func() or bli_l3_cntl_free()
    trying to access freed gl_comm → CRASH!
    trying to access freed array pools → CRASH!
```

This is **exactly the same issue** that PR #702 fixed in other files! The function needs a barrier before threads exit the parallel region to ensure:

1. **All threads complete their work** before any cleanup starts
2. **Global communicator isn't freed** while other threads are using it
3. **Array pools aren't freed** while other threads are accessing them
2025-11-07 10:49:19 +05:30
Varaganti, Kiran
7ac261b173 Replaced omp barrier with bli_thread_barrier and added similar fix fo… (#248)
* Replaced omp barrier with bli_thread_barrier and added similar fix for pack compute routine

## **The Sequence is Critical:**

1. **All threads execute `func(...)`** - may access shared resources including communicators
2. **Barrier ** - ensures ALL threads finish their work
3. **Then each thread calls `bli_l3_sup_thrinfo_free()`** - only chief actually frees gl_comm
4. **Safe cleanup** - no use-after-free because all threads are done using gl_comm

## **What Would Happen Without the Barrier:**

```c
// Thread execution timeline WITHOUT barrier:
Time 1: Thread 0 finishes func() early → immediately calls bli_l3_sup_thrinfo_free()
Time 2: Thread 0 (chief) frees gl_comm
Time 3: Thread 1,2,3... still in func() → try to use freed gl_comm → CRASH!
```

## **With the Barrier (Current Safe Code):**

```c
// Thread execution timeline WITH barrier:
Time 1: All threads finish func() at different times
Time 2: ALL threads reach barrier → wait for slowest thread
Time 3: ALL threads proceed past barrier together  
Time 4: Chief frees gl_comm → safe because no one using it anymore
```
2025-10-31 10:01:40 +05:30
Varaganti, Kiran
49961aa569 Fix DTL dynamic thread logging in BLAS operations (#230)
- Remove redundant AOCL_DTL_LOG_NUM_THREADS calls from early return paths
- Update thread count logging to use AOCL_get_requested_threads_count() for early exits
- Clean up duplicate DTL logging in gemv_unf_var1 and gemv_unf_var2 implementations
- Remove thread count logging from bli_dgemv_n_zen4_int kernel variants
- Simplify aocldtl_blis.c AOCL_DTL_log_gemv_sizes by removing redundant conditional
- Standardize DTL trace exit patterns across axpy, scal, and gemv operations
- Remove commented-out DTL logging code in zen4 gemv kernel

This patch ensures thread count is logged only once per operation and uses
the correct API (AOCL_get_requested_threads_count) for early exit scenarios
where the actual execution thread count may differ from requested threads.
AOCL-Weekly-241025
2025-10-24 13:34:00 +01:00
Dave, Harsh
90d252d59a Add OpenMP barrier before releasing threadinfo & global communicator to avoid race (#225)
- Added `#pragma omp barrier` just before threads start releasing their threadinfo / global
  communicator.
- This ensures all threads reach this sync point, preventing interleaved cleanup.

Co-authored-by: harsdave <harsdave@amd.com>
2025-10-24 16:22:45 +05:30
S, Hari Govind
ab25b825aa Fix: Resolve Operator Precedence Warning in Zen5 DCOMPLEX Threshold Logic
- Add explicit parentheses around (n <= 1520) && (k <= 128) to clarify
  operator precedence and resolve compiler warning. The intended logic
  is (m <= 1380) OR (n <= 1520 AND k <= 128).

- This change eliminates the compiler warning about mixing || and &&
  operators without explicit grouping.
2025-10-24 14:23:23 +05:30
Rayan, Rohan
e85be22da0 Adding tiny path for SGEMM (#237)
Adding SGEMM tiny path for Zen architectures.
Needed to cover some performance gaps seen wrt MKL
Only allowing matrices that all fit into the L1 cache to the tiny path
Only tuned for single threaded operation at the moment
Todo: Tune cases where AVX2 performs better than AVX512 on Zen4
Todo: The current ranges are very conservative, there may be scope to increase the matrix sizes that go into the tiny path

AMD-Internal: CPUPL-7555
Co-authored-by: Rohan Rayan rohrayan@amd.com
2025-10-24 13:14:33 +05:30
V, Varsha
fecb1aa7a5 Bug Fix in BF16 AVX2 conversion path (#236)
- In the current implementation of bf16 to f32 conversion for packed data
 we handle both GEMM and GEMV conditions in the same function separated
 with conditions.
 - But, when n = (NC+1) the function would execute GEMV conversion logic
 and write back the data inaccurately leading to accuracy issues.
 - Hence, modified the convert function and reorder functions to have
 separate conversion logic to make it cleaner and avoid confusions.
 -  Also, updated the API calls to adhere to the changes appropriately.

[AMD-Internal: CPUPL-7540]
2025-10-17 15:38:02 +05:30
S, Hari Govind
0ce45e3147 Changing ZGEMM SUP threshold logic for zen5 to fix performance regression (#233)
- Revert the logical operator from OR (||) to AND (&&) in the DCOMPLEX
  (ZGEMM) SUP threshold condition for k <= 128. The previous change to
  OR logic was causing performance regressions for certain input sizes
  by incorrectly routing cases to the SUP path when the native path
  would be more optimal.
2025-10-17 11:25:33 +05:30
Sharma, Shubham
1dca574a9d Improved fringe case handling for AVXPV kernel (#228)
- Current kernel uses masked AVX512 instructions to handle fringe cases.
- These instructions are slow on genoa.
- To handle sizes less than 8, AVX2 and SSE code has been added.
- Existing masked AVX512 code is performing better when n > 8 therefore it is still kept for handling larger sizes where n % 8 != 0.

AMD-Internal: [CPUPL-7467]
AOCL-Oct2025-b2
2025-10-10 14:25:35 +05:30
Varaganti, Kiran
e857899cb3 Added dynamic threads and actual threads in the DTL log of SAXPY (#224) 2025-10-08 10:25:25 +05:30
Smyth, Edward
804d4a9f38 Compiler warnings fixes (3)
Recent changes meant nt was defined but unused for serial builds
when DTL was not enabled. Restructure code to avoid this issue and
make the code more readable.

AMD-Internal: [CPUPL-6579]
2025-10-03 11:51:10 +01:00
Rayan, Rohan
dc4e0f72c1 Fixing an integer division in GEMV that was supposed to be a double operation (#218)
---------

Co-authored-by: Rayan <rohrayan@amd.com>
2025-09-30 14:04:39 +05:30
Prabhu, Anantha
f0f5b4c612 Update codeql_cpp_placeholder.yml
Update codeql_cpp_placeholder file to stop running it for each PR.
2025-09-26 12:04:43 +05:30
Prabhu, Anantha
9933093239 Add CodeQL analysis workflow for C/C++ and Python
Adding CodeQL advanced analysis workflow for C/C++ and Python
2025-09-26 11:33:38 +05:30
Dave, Harsh
c9933886f7 Tuned zgemm threshold for zen5 (#215)
Threshold tuning that determines whether SUP or native path should
be used for given input matrix size.

This tuning forces skinny matrices to take SUP path to ensure better
performance.

AMD-Internal: [CPUPL-7369]

Co-authored-by: harsh dave <harsdave@amd.com>
2025-09-23 08:05:31 +05:30
Bhaskar, Nallani
db3134ed6d Disabled no post-ops path in lpgemm f32 kernels for few gcc versions
Guarded np (no post-ops) path in f32 API with a macro 
 as a workaround as gcc 11.4 and 11.2 are giving accuracy issues 
 with np path.
2025-09-22 15:52:21 +05:30
Varaganti, Kiran
807de2a990 DTL Log update
* DTL Log update
Updates logs with nt and AOCL Dynamic selected nt for axpy, scal and dgemv
Modified bench_gemv.c to able to process modified dtl logs.

* Updated DTL log for copy routine with actual nt and dynamic nt

* Refactor OpenMP pragmas and clean up code

Removed unnecessary nested OpenMP pragma and cleaned up function end comment.

* Fixed DTL log for sequential build

* Added thread logging in bla_gemv_check for invalid inputs

---------

Co-authored-by: Smyth, Edward <Edward.Smyth@amd.com>
2025-09-22 11:32:00 +05:30
Chandrashekara K R
03685d1ad9 Add external PR integration process and flowchart to CONTRIBUTING.md
1. Documented the process for handling external pull requests,
   including validation, review, and notification steps.
2. Added a markdown flowchart illustrating the PR workflow.
3. Included communication and contributor attribution notes.
2025-09-19 22:46:25 +05:30
Dave, Harsh
7076294286 Enabled disable-sba-pools feature in AOCL-BLAS (#101)
Co-authored-by: harsh dave <harsdave@amd.com>
2025-09-19 21:45:08 +05:30
Sharma, Arnav
ee3d250b7a Fix for F32 to BF16 Conversion and AVX512 ISA Support Checks
- Fixed register assignment bug in lpgemv_m_kernel_f32_avx512 where zmm3
  was incorrectly used instead of zmm4 in BF16_F32_BETA_OP_NLT16F_MASK macro.

- Replaced hardware-specific BF16 conversion intrinsics with manual
  rounding, bit manipulation and F32 instruction set for compatibility on
  hardware without native BF16 support.

- Added AVX512_BF16 ISA support checks for s8s8s32obf16 and u8s8s32obf16
  GEMM operations to ensure processor compatibility before execution.

AMD-Internal: [CPUPL-7410]
AOCL-Weekly-190925
2025-09-19 18:49:33 +05:30
Varaganti, Kiran
ec5cf7d174 Fixed Integer Overflow Issue in TPSV
- In the TPSV APIs, operations such as (*n - 1) * *incx and *n * (*n + 1) may lead to overflow when using bla_integer. To mitigate this risk, these operations have been updated to use dim_t variables instead of bla_integer.
2025-09-19 14:58:35 +05:30
pr_platform, a1
bf984462c7 Add AI Code Review workflow (#211)
Automated enablement of AI Code Review capabilities
2025-09-19 14:12:33 +05:30
Rao, Pradeep
91e01fbeac Add AI Code Review Self-enablement file (#209)
This will enable triggering AI Code Review tool when PR is raised
2025-09-19 13:39:53 +05:30
Sharma, Shubham
773d3a3d45 Re-tuned GEMV thresholds (#210)
Retune DGEMV AVX512 non transpose thresholds to avoid regression on ZEN4.

AMD-Internal: [CPUPL-7448]
2025-09-19 12:43:50 +05:30
S, Hari Govind
a9df3fd8d5 Adding bli_print_msg before bli_abort() for bli_thrinfo_sup_create_for_cntl
- Adding bli_print_msg to print failure message bout bli_abort in
  bli_thrinfo_sup_create_for_cntl function.
2025-09-19 10:53:50 +05:30
Smyth, Edward
823ec2cd40 Add missing license text
Some files have copyright statements but not details of the license.
Add this to DTL source code and some build and benchmark related
scripts.

AMD-Internal: [CPUPL-6579]
2025-09-18 12:04:59 +01:00
Sharma, Shubham
10b2e59782 Modified AVPY kernel to ensure consistency of numerical results (#188)
Current DAXPY kernel uses C code to solve cases when n %8 != 0.
This results in the compiled code using MUL+ADD instruction using SSE, instead of FMA instruction.
This causes inconsistency of numerical results.
To fix this, AVX2 and C code is replaced with masked AVX512 instructions to compute fringe cases.

AMD-Internal : [CPUPL-7315]
2025-09-18 11:42:31 +05:30
Sharma, Shubham
740fbdf50d Fix memory leak in DGEMV kernel (#187)
Memory is not freed for GEMV when MT kernel with called for NT = 1;
Fixed this by adding an extra check to make sure memory is freed.

AMD-Internal: [CPUPL-7352]
2025-09-18 11:18:13 +05:30
Sharma, Shubham
a02020686c Tuned DGEMV no-transpose thresholds #193
In order to avoid regression in some sizes, thresholds are retuned and scope of 32x8 kernels is expanded.

AMD-Internal:[CPUPL-7336]
2025-09-18 10:50:09 +05:30
Sharma, Shubham
c9d4bb6778 Set Security flags default enable (#194)
AMD-Internal: [CPUPL-7426]
2025-09-18 10:29:08 +05:30
Smyth, Edward
e3b22f495e Standardize Zen kernel names (2)
Further changes to fix inconsistencies in naming of zen kernels.

AMD-Internal: [CPUPL-6579]
2025-09-17 21:48:34 +01:00
Smyth, Edward
e59eabaf58 Compiler warnings fixes (2)
Fix compiler warning messages in LPGEMM code:
- Removed extraneous parentheses in aocl_batch_gemm_s8s8s32os32.c
- Removed unused variables in lpgemv_{m,n}_kernel_s8_grp_amd512vnni.c
- Changed ERR_UBOUND in math_utils_avx2.h and math_utils_avx512.h
  to match how it is specified in AOCL libm erff.c

AMD-Internal: [CPUPL-6579]
2025-09-17 18:28:34 +01:00
Dave, Harsh
31aba514fe coverity issue fix for ztrsm (#176)
* Fixed coverity issue in ztrsm small code path

* Fixed coverity issue in ztrsm small code path

---------

Co-authored-by: harsh dave <harsdave@amd.com>
2025-09-17 19:39:12 +05:30
Dave, Harsh
a2526a2593 Fixes Coverity static analysis issue in the DTRSM (#181)
* Fixes Coverity static analysis issue in the DTRSM

- Initializes ps_a_use variable and calls bli_auxinfo_set_ps_a() to set
  pack stride in auxinfo structure.

* Fixed unintialized variable issue in the DTRSM

- Initializes ps_a_use variable and calls bli_auxinfo_set_ps_a() to set
  pack stride in auxinfo structure.

---------

Co-authored-by: harsdave <harsdave@amd.com>
2025-09-17 18:02:45 +05:30
Prabhu, Anantha
293e406f48 Add files via upload (#197) 2025-09-17 15:53:44 +05:30
S, Hari Govind
08c757202d Initialize mem_t structures safely and handle NULL communicator in threading
- Explicitly initialize all fields of mem_t structures in bli_znormfv_unb_var1 and bli_dnormfv_unb_var1 to prevent undefined behavior when memory is not allocated.
- Add a NULL check after bli_thread_broadcast() in bli_thrinfo_sup_create_for_cntl to ensure that the communicator is valid, and call bli_abort() if broadcast fails.
2025-09-17 14:10:37 +05:30
Smyth, Edward
ae6c7d86df Tidying code
- AMD specific BLAS1 and BLAS2 franework: changes to make variants
  more consistent with each other
- Initialize kernel pointers to NULL where not immediately set
- Fix code indentation and other other whitespace changes in DTL
  code and addon/aocl_gemm/frame/s8s8s32/lpgemm_s8s8s32_sym_quant.c
- Fix typos in DTL comments
- Add missing newline at end of test/CMakeLists.txt
- Standardize on using arch_id variable name

AMD-Internal: [CPUPL-6579]
2025-09-16 14:52:54 +01:00
Smyth, Edward
a4fdad5dde Compiler warnings fixes
Fix compiler warnings for unused variables. Situations where they
occurred were:
- bla_gemm_amd.c: Builds not including AMD zen4 or zen5 codepaths.
- bla_trsm_amd.c: Builds where {M,N,K]=1 optimizations are disabled.
- Avoid warnings when DTL is not enabled.

AMD-Internal: [CPUPL-6579]
2025-09-16 13:56:01 +01:00
Rayan, Rohan
2e7f387d13 Fixing the coverity issues with CID: 23269 and CID: 137049 (#180)
Fixing some coverity issues that detected out of bounds array accesses.

AMD-Internal: CPUPL-6579
Co-authored-by: Rohan Rayan rohrayan@amd.com
2025-09-16 10:01:52 +05:30
KadavilMadanaMohanan, MithunMohan (Mithun Mohan)
5de25ce9a7 Fixed high priority coverity issues in LPGEMM. (#178)
* Fixed high priority coverity issues in LPGEMM.

-Out of bounds issue and uninitialized variables fixed in aocl_gemm addon.
2025-09-11 18:27:19 +05:30
Smyth, Edward
a4db661b44 GCC 15 SUP kernel workaround (2)
Previous commit (30c42202d7) for this problem turned off
-ftree-slp-vectorize optimizations for all kernels. Instead, copy
the approach of upstream BLIS commit 36effd70b6a323856d98 and disable
these optimizations only for the affected files by using GCC pragmas

AMD-Internal: [CPUPL-6579]
2025-09-04 17:14:06 +01:00
Dave, Harsh
197165318c Disable small_gemm for zen4/5 and added single thread check for tiny path (#167)
* Check for single thread or multi-thread execution

- Check for single or multi-threaded call to dgemm.
- If it is single threaded, dgemm is computed in tiny path
  if inputs under threashold.
- If it is multi-threaded dgemm input, tiny path will evaluate
  whether it is performant compute the given input with single
  thread or not. Based on that input will be routed.

* Disable gemm_small on zen4/5 & single thread execution check for tiny path

- Check for single or multi-threaded call to dgemm.
- If it is single threaded, dgemm is computed in tiny path
  if inputs under threashold.
- If it is multi-threaded dgemm input, tiny path will evaluate
  whether it is performant compute the given input with single
  thread or not. Based on that input will be routed.
- Architecture checks for zen3, zen2 and zen are placed
  for gemm_small path.

---------

Co-authored-by: harsdave <harsdave@amd.com>
2025-09-04 20:41:21 +05:30
Balasubramanian, Vignesh
37f255821a Optimal rerouting of GEMV inputs to avoid packing
- Added conditional swapping of input matrices and their
  strides for GEMV, based on whether transpose is toggled
  specifically for the matrix, namely the B matrix when m=1
  and the A matrix when n=1.

- This swapping ensures that we reroute the inputs to use the
  alternative variant(code-path) in order to avoid packing cost
  for the matrix, through logical transposition.

- Currently, this optimization is enabled only when no post-ops
  are involved. With post-ops, there is a need to update the
  incoming data(from the user) in some scenarios, which will be
  dealt with later.

AMD-Internal: [CPUPL-7323]

Co-authored-by: Vignesh Balasubramanian <vignbala@amd.com>
2025-09-03 09:15:59 +05:30