You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

sbgemv_n_microk_cooperlake.c 3.5 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /***************************************************************************
  2. Copyright (c) 2014, The OpenBLAS Project
  3. All rights reserved.
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions are
  6. met:
  7. 1. Redistributions of source code must retain the above copyright
  8. notice, this list of conditions and the following disclaimer.
  9. 2. Redistributions in binary form must reproduce the above copyright
  10. notice, this list of conditions and the following disclaimer in
  11. the documentation and/or other materials provided with the
  12. distribution.
  13. 3. Neither the name of the OpenBLAS project nor the names of
  14. its contributors may be used to endorse or promote products
  15. derived from this software without specific prior written permission.
  16. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  17. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  18. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  19. ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE
  20. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  21. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  22. SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  23. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  24. OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
  25. USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. *****************************************************************************/
  27. /* need a new enough GCC for avx512 support */
  28. #if (( defined(__GNUC__) && __GNUC__ >= 10 && defined(__AVX512BF16__)) || (defined(__clang__) && __clang_major__ >= 9))
  29. #define HAVE_SBGEMV_N_ACCL_KERNEL 1
  30. #include "common.h"
  31. #include <immintrin.h>
  32. // Define micro kernels for ALPHA not ONE && BETA effective && BETA not ONE scenarios
  33. #undef ZERO_BETA
  34. #undef ONE_BETA
  35. #undef ONE_ALPHA
  36. #include "sbgemv_n_microk_cooperlake_template.c"
  37. // Define micro kernels for ALPHA not ONE && BETA as ONE scenarios
  38. #undef ZERO_BETA
  39. #define ONE_BETA 1
  40. #undef ONE_ALPHA
  41. #include "sbgemv_n_microk_cooperlake_template.c"
  42. // Define micro kernels for ALPHA not ONE && BETA in-effective (BETA == 0) scenarios
  43. #define ZERO_BETA 1
  44. #undef ONE_ALPHA
  45. #include "sbgemv_n_microk_cooperlake_template.c"
  46. // Define micro kernels for ALPHA as ONE && BETA in-effective (BETA == 0) scenarios
  47. #define ZERO_BETA 1
  48. #define ONE_ALPHA 1
  49. #include "sbgemv_n_microk_cooperlake_template.c"
  50. static int sbgemv_kernel_n(BLASLONG m, BLASLONG n, float alpha, bfloat16 *a, BLASLONG lda, bfloat16 *x, float beta, float *y)
  51. {
  52. if (beta == ZERO) { // BETA == 0.0, no need to accumulate the original Y data
  53. if (alpha == ONE) { // ALPHA == 1.0, no need to multipy ALPHA
  54. sbgemv_kernel_32xN_lda_direct(m, n, alpha, a, lda, x, y);
  55. } else { // ALPHA != 1.0, need to multipy ALPHA
  56. sbgemv_kernel_32xN_lda_direct_alpha(m, n, alpha, a, lda, x, y);
  57. }
  58. } else { // BETA != 0.0, need to accumulate the original Y data no matter what ALPHA is
  59. if (beta == ONE) {
  60. sbgemv_kernel_32xN_lda_direct_alpha_one(m, n, alpha, a, lda, x, beta, y);
  61. } else {
  62. sbgemv_kernel_32xN_lda_direct_alpha_beta(m, n, alpha, a, lda, x, beta, y);
  63. }
  64. }
  65. return 0;
  66. }
  67. #endif