| 1 | /* |
| 2 | |
| 3 | BLIS |
| 4 | An object-based framework for developing high-performance BLAS-like |
| 5 | libraries. |
| 6 | |
| 7 | Copyright (C) 2014, The University of Texas at Austin |
| 8 | |
| 9 | Redistribution and use in source and binary forms, with or without |
| 10 | modification, are permitted provided that the following conditions are |
| 11 | met: |
| 12 | - Redistributions of source code must retain the above copyright |
| 13 | notice, this list of conditions and the following disclaimer. |
| 14 | - Redistributions in binary form must reproduce the above copyright |
| 15 | notice, this list of conditions and the following disclaimer in the |
| 16 | documentation and/or other materials provided with the distribution. |
| 17 | - Neither the name(s) of the copyright holder(s) nor the names of its |
| 18 | contributors may be used to endorse or promote products derived |
| 19 | from this software without specific prior written permission. |
| 20 | |
| 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 22 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 23 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 24 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 25 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 26 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 27 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 28 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 29 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 30 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 31 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 32 | |
| 33 | */ |
| 34 | |
| 35 | #include "../../kernels/rviv/3/bli_rviv_utils.h" |
| 36 | |
| 37 | void bli_cntx_init_rv32iv( cntx_t* cntx ) |
| 38 | { |
| 39 | blksz_t blkszs[ BLIS_NUM_BLKSZS ]; |
| 40 | |
| 41 | // Set default kernel blocksizes and functions. |
| 42 | bli_cntx_init_rv32iv_ref( cntx ); |
| 43 | |
| 44 | // ------------------------------------------------------------------------- |
| 45 | |
| 46 | // A reasonable assumptions for application cores is VLEN >= 128 bits, i.e., |
| 47 | // v >= 4. Embedded cores, however, may implement the minimal configuration, |
| 48 | // which allows VLEN = 32 bits. Here, we assume VLEN >= 128 and otherwise |
| 49 | // fall back to the reference kernels. |
| 50 | const uint32_t v = get_vlenb() / sizeof(float); |
| 51 | |
| 52 | if ( v >= 4 ) |
| 53 | { |
| 54 | const uint32_t mr_s = 4 * v; |
| 55 | const uint32_t mr_d = 2 * v; |
| 56 | const uint32_t mr_c = 2 * v; |
| 57 | const uint32_t mr_z = v; |
| 58 | |
| 59 | // Update the context with optimized native gemm micro-kernels. |
| 60 | bli_cntx_set_ukrs |
| 61 | ( |
| 62 | cntx, |
| 63 | |
| 64 | // level-3 |
| 65 | BLIS_GEMM_UKR, BLIS_FLOAT, bli_sgemm_rviv_4vx4, |
| 66 | BLIS_GEMM_UKR, BLIS_DOUBLE, bli_dgemm_rviv_4vx4, |
| 67 | BLIS_GEMM_UKR, BLIS_SCOMPLEX, bli_cgemm_rviv_4vx4, |
| 68 | BLIS_GEMM_UKR, BLIS_DCOMPLEX, bli_zgemm_rviv_4vx4, |
| 69 | |
| 70 | BLIS_VA_END |
| 71 | ); |
| 72 | |
| 73 | // Update the context with storage preferences. |
| 74 | bli_cntx_set_ukr_prefs |
| 75 | ( |
| 76 | cntx, |
| 77 | |
| 78 | // level-3 |
| 79 | BLIS_GEMM_UKR_ROW_PREF, BLIS_FLOAT, FALSE, |
| 80 | BLIS_GEMM_UKR_ROW_PREF, BLIS_DOUBLE, FALSE, |
| 81 | BLIS_GEMM_UKR_ROW_PREF, BLIS_SCOMPLEX, FALSE, |
| 82 | BLIS_GEMM_UKR_ROW_PREF, BLIS_DCOMPLEX, FALSE, |
| 83 | |
| 84 | BLIS_VA_END |
| 85 | ); |
| 86 | |
| 87 | // Initialize level-3 blocksize objects with architecture-specific values. |
| 88 | // s d c z |
| 89 | bli_blksz_init_easy( &blkszs[ BLIS_MR ], mr_s, mr_d, mr_c, mr_z ); |
| 90 | bli_blksz_init_easy( &blkszs[ BLIS_NR ], 4, 4, 4, 4 ); |
| 91 | bli_blksz_init_easy( &blkszs[ BLIS_MC ], 20*mr_s, 20*mr_d, 60*mr_c, 30*mr_z ); |
| 92 | bli_blksz_init_easy( &blkszs[ BLIS_KC ], 640, 320, 320, 160 ); |
| 93 | bli_blksz_init_easy( &blkszs[ BLIS_NC ], 3072, 3072, 3072, 3072 ); |
| 94 | |
| 95 | bli_cntx_set_blkszs |
| 96 | ( |
| 97 | cntx, |
| 98 | |
| 99 | // level-3 |
| 100 | BLIS_NC, &blkszs[ BLIS_NC ], BLIS_NR, |
| 101 | BLIS_KC, &blkszs[ BLIS_KC ], BLIS_KR, |
| 102 | BLIS_MC, &blkszs[ BLIS_MC ], BLIS_MR, |
| 103 | BLIS_NR, &blkszs[ BLIS_NR ], BLIS_NR, |
| 104 | BLIS_MR, &blkszs[ BLIS_MR ], BLIS_MR, |
| 105 | |
| 106 | BLIS_VA_END |
| 107 | ); |
| 108 | } |
| 109 | } |