Austin Schuh | 9a24b37 | 2018-01-28 16:12:29 -0800 | [diff] [blame^] | 1 | /************************************************************************************************** |
| 2 | * * |
| 3 | * This file is part of BLASFEO. * |
| 4 | * * |
| 5 | * BLASFEO -- BLAS For Embedded Optimization. * |
| 6 | * Copyright (C) 2016-2017 by Gianluca Frison. * |
| 7 | * Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * |
| 8 | * All rights reserved. * |
| 9 | * * |
| 10 | * HPMPC is free software; you can redistribute it and/or * |
| 11 | * modify it under the terms of the GNU Lesser General Public * |
| 12 | * License as published by the Free Software Foundation; either * |
| 13 | * version 2.1 of the License, or (at your option) any later version. * |
| 14 | * * |
| 15 | * HPMPC is distributed in the hope that it will be useful, * |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * |
| 18 | * See the GNU Lesser General Public License for more details. * |
| 19 | * * |
| 20 | * You should have received a copy of the GNU Lesser General Public * |
| 21 | * License along with HPMPC; if not, write to the Free Software * |
| 22 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * |
| 23 | * * |
| 24 | * Author: Gianluca Frison, giaf (at) dtu.dk * |
| 25 | * gianluca.frison (at) imtek.uni-freiburg.de * |
| 26 | * * |
| 27 | **************************************************************************************************/ |
| 28 | |
| 29 | #include <stdlib.h> |
| 30 | #include <stdio.h> |
| 31 | #include <sys/time.h> |
| 32 | |
| 33 | |
| 34 | #include "../include/blasfeo_common.h" |
| 35 | #include "../include/blasfeo_s_aux_ext_dep.h" |
| 36 | #include "../include/blasfeo_i_aux_ext_dep.h" |
| 37 | #include "../include/blasfeo_s_aux.h" |
| 38 | #include "../include/blasfeo_s_kernel.h" |
| 39 | #include "../include/blasfeo_s_blas.h" |
| 40 | |
| 41 | #ifndef S_PS |
| 42 | #define S_PS 1 |
| 43 | #endif |
| 44 | #ifndef S_NC |
| 45 | #define S_NC 1 |
| 46 | #endif |
| 47 | |
| 48 | |
| 49 | |
| 50 | #if defined(REF_BLAS_OPENBLAS) |
| 51 | void openblas_set_num_threads(int num_threads); |
| 52 | #endif |
| 53 | #if defined(REF_BLAS_BLIS) |
| 54 | void omp_set_num_threads(int num_threads); |
| 55 | #endif |
| 56 | #if defined(REF_BLAS_MKL) |
| 57 | #include "mkl.h" |
| 58 | #endif |
| 59 | |
| 60 | |
| 61 | |
| 62 | #include "cpu_freq.h" |
| 63 | |
| 64 | |
| 65 | |
| 66 | int main() |
| 67 | { |
| 68 | |
| 69 | #if defined(REF_BLAS_OPENBLAS) |
| 70 | openblas_set_num_threads(1); |
| 71 | #endif |
| 72 | #if defined(REF_BLAS_BLIS) |
| 73 | omp_set_num_threads(1); |
| 74 | #endif |
| 75 | #if defined(REF_BLAS_MKL) |
| 76 | mkl_set_num_threads(1); |
| 77 | #endif |
| 78 | |
| 79 | printf("\n"); |
| 80 | printf("\n"); |
| 81 | printf("\n"); |
| 82 | |
| 83 | printf("BLAS performance test - float precision\n"); |
| 84 | printf("\n"); |
| 85 | |
| 86 | // maximum frequency of the processor |
| 87 | const float GHz_max = GHZ_MAX; |
| 88 | printf("Frequency used to compute theoretical peak: %5.1f GHz (edit test_param.h to modify this value).\n", GHz_max); |
| 89 | printf("\n"); |
| 90 | |
| 91 | // maximum flops per cycle, single precision |
| 92 | // maxumum memops (sustained load->store of floats) per cycle, single precision |
| 93 | #if defined(TARGET_X64_INTEL_HASWELL) |
| 94 | const float flops_max = 32; // 2x256 bit fma |
| 95 | const float memops_max = 8; // 2x256 bit load + 1x256 bit store |
| 96 | printf("Testing BLAS version for AVX2 and FMA instruction sets, 64 bit (optimized for Intel Haswell): theoretical peak %5.1f Gflops\n", flops_max*GHz_max); |
| 97 | #elif defined(TARGET_X64_INTEL_SANDY_BRIDGE) |
| 98 | const float flops_max = 16; // 1x256 bit mul + 1x256 bit add |
| 99 | const float memops_max = 4; // 1x256 bit load + 1x128 bit store |
| 100 | printf("Testing BLAS version for AVX instruction set, 64 bit (optimized for Intel Sandy Bridge): theoretical peak %5.1f Gflops\n", flops_max*GHz_max); |
| 101 | #elif defined(TARGET_X64_INTEL_CORE) |
| 102 | const float flops_max = 8; // 1x128 bit mul + 1x128 bit add |
| 103 | const float memops_max = 4; // 1x128 bit load + 1x128 bit store; |
| 104 | printf("Testing BLAS version for SSE3 instruction set, 64 bit (optimized for Intel Core): theoretical peak %5.1f Gflops\n", flops_max*GHz_max); |
| 105 | #elif defined(TARGET_X64_AMD_BULLDOZER) |
| 106 | const float flops_max = 16; // 2x128 bit fma |
| 107 | const float memops_max = 4; // 1x256 bit load + 1x128 bit store |
| 108 | printf("Testing BLAS version for SSE3 and FMA instruction set, 64 bit (optimized for AMD Bulldozer): theoretical peak %5.1f Gflops\n", flops_max*GHz_max); |
| 109 | #elif defined(TARGET_ARMV8A_ARM_CORTEX_A57) |
| 110 | const float flops_max = 8; // 1x128 bit fma |
| 111 | const float memops_max = 4; // ??? |
| 112 | printf("Testing BLAS version for VFPv4 instruction set, 32 bit (optimized for ARM Cortex A15): theoretical peak %5.1f Gflops\n", flops_max*GHz_max); |
| 113 | #elif defined(TARGET_ARMV7A_ARM_CORTEX_A15) |
| 114 | const float flops_max = 8; // 1x128 bit fma |
| 115 | const float memops_max = 4; // ??? |
| 116 | printf("Testing BLAS version for VFPv4 instruction set, 32 bit (optimized for ARM Cortex A15): theoretical peak %5.1f Gflops\n", flops_max*GHz_max); |
| 117 | #elif defined(TARGET_GENERIC) |
| 118 | const float flops_max = 2; // 1x32 bit mul + 1x32 bit add ??? |
| 119 | const float memops_max = 1; // ??? |
| 120 | printf("Testing BLAS version for generic scalar instruction set: theoretical peak %5.1f Gflops ???\n", flops_max*GHz_max); |
| 121 | #endif |
| 122 | |
| 123 | // FILE *f; |
| 124 | // f = fopen("./test_problems/results/test_blas.m", "w"); // a |
| 125 | |
| 126 | #if defined(TARGET_X64_INTEL_HASWELL) |
| 127 | // fprintf(f, "C = 's_x64_intel_haswell';\n"); |
| 128 | // fprintf(f, "\n"); |
| 129 | #elif defined(TARGET_X64_INTEL_SANDY_BRIDGE) |
| 130 | // fprintf(f, "C = 's_x64_intel_sandybridge';\n"); |
| 131 | // fprintf(f, "\n"); |
| 132 | #elif defined(TARGET_X64_INTEL_CORE) |
| 133 | // fprintf(f, "C = 's_x64_intel_core';\n"); |
| 134 | // fprintf(f, "\n"); |
| 135 | #elif defined(TARGET_X64_AMD_BULLDOZER) |
| 136 | // fprintf(f, "C = 's_x64_amd_bulldozer';\n"); |
| 137 | // fprintf(f, "\n"); |
| 138 | #elif defined(TARGET_ARMV8A_ARM_CORTEX_A57) |
| 139 | // fprintf(f, "C = 's_armv7a_arm_cortex_a15';\n"); |
| 140 | // fprintf(f, "\n"); |
| 141 | #elif defined(TARGET_ARMV7A_ARM_CORTEX_A15) |
| 142 | // fprintf(f, "C = 's_armv7a_arm_cortex_a15';\n"); |
| 143 | // fprintf(f, "\n"); |
| 144 | #elif defined(TARGET_GENERIC) |
| 145 | // fprintf(f, "C = 's_generic';\n"); |
| 146 | // fprintf(f, "\n"); |
| 147 | #endif |
| 148 | |
| 149 | // fprintf(f, "A = [%f %f];\n", GHz_max, flops_max); |
| 150 | // fprintf(f, "\n"); |
| 151 | |
| 152 | // fprintf(f, "B = [\n"); |
| 153 | |
| 154 | |
| 155 | |
| 156 | int i, j, rep, ll; |
| 157 | |
| 158 | const int bss = S_PS; |
| 159 | const int ncs = S_NC; |
| 160 | |
| 161 | /* int info = 0;*/ |
| 162 | |
| 163 | printf("\nn\t sgemm_blasfeo\t sgemm_blas\n"); |
| 164 | printf("\nn\t Gflops\t %%\t Gflops\t %%\n\n"); |
| 165 | |
| 166 | #if 1 |
| 167 | int nn[] = {4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 84, 88, 92, 96, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144, 148, 152, 156, 160, 164, 168, 172, 176, 180, 184, 188, 192, 196, 200, 204, 208, 212, 216, 220, 224, 228, 232, 236, 240, 244, 248, 252, 256, 260, 264, 268, 272, 276, 280, 284, 288, 292, 296, 300, 304, 308, 312, 316, 320, 324, 328, 332, 336, 340, 344, 348, 352, 356, 360, 364, 368, 372, 376, 380, 384, 388, 392, 396, 400, 404, 408, 412, 416, 420, 424, 428, 432, 436, 440, 444, 448, 452, 456, 460, 500, 550, 600, 650, 700}; |
| 168 | int nnrep[] = {10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 400, 400, 400, 400, 400, 200, 200, 200, 200, 200, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 20, 20, 20, 20, 20, 20, 20, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 4, 4, 4, 4, 4}; |
| 169 | |
| 170 | // for(ll=0; ll<24; ll++) |
| 171 | for(ll=0; ll<75; ll++) |
| 172 | // for(ll=0; ll<115; ll++) |
| 173 | // for(ll=0; ll<120; ll++) |
| 174 | |
| 175 | { |
| 176 | |
| 177 | int n = nn[ll]; |
| 178 | int nrep = nnrep[ll]; |
| 179 | // int n = ll+1; |
| 180 | // int nrep = nnrep[0]; |
| 181 | // n = n<16 ? 16 : n; |
| 182 | |
| 183 | int n2 = n*n; |
| 184 | |
| 185 | #else |
| 186 | int nn[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}; |
| 187 | |
| 188 | for(ll=0; ll<24; ll++) |
| 189 | |
| 190 | { |
| 191 | |
| 192 | int n = nn[ll]; |
| 193 | int nrep = 40000; //nnrep[ll]; |
| 194 | #endif |
| 195 | |
| 196 | float *A; s_zeros(&A, n, n); |
| 197 | float *B; s_zeros(&B, n, n); |
| 198 | float *C; s_zeros(&C, n, n); |
| 199 | float *M; s_zeros(&M, n, n); |
| 200 | |
| 201 | char c_n = 'n'; |
| 202 | char c_l = 'l'; |
| 203 | char c_r = 'r'; |
| 204 | char c_t = 't'; |
| 205 | char c_u = 'u'; |
| 206 | int i_1 = 1; |
| 207 | int i_t; |
| 208 | float d_1 = 1; |
| 209 | float d_0 = 0; |
| 210 | |
| 211 | for(i=0; i<n*n; i++) |
| 212 | A[i] = i; |
| 213 | |
| 214 | for(i=0; i<n; i++) |
| 215 | B[i*(n+1)] = 1; |
| 216 | |
| 217 | for(i=0; i<n*n; i++) |
| 218 | M[i] = 1; |
| 219 | |
| 220 | float *B2; s_zeros(&B2, n, n); |
| 221 | for(i=0; i<n*n; i++) |
| 222 | B2[i] = 1e-15; |
| 223 | for(i=0; i<n; i++) |
| 224 | B2[i*(n+1)] = 1; |
| 225 | |
| 226 | float *x; s_zeros(&x, n, 1); |
| 227 | float *y; s_zeros(&y, n, 1); |
| 228 | float *x2; s_zeros(&x2, n, 1); |
| 229 | float *y2; s_zeros(&y2, n, 1); |
| 230 | float *diag; s_zeros(&diag, n, 1); |
| 231 | int *ipiv; int_zeros(&ipiv, n, 1); |
| 232 | |
| 233 | // for(i=0; i<n; i++) x[i] = 1; |
| 234 | // for(i=0; i<n; i++) x2[i] = 1; |
| 235 | |
| 236 | // matrix struct |
| 237 | #if 0 |
| 238 | struct s_strmat sA; s_allocate_strmat(n+4, n+4, &sA); |
| 239 | struct s_strmat sB; s_allocate_strmat(n+4, n+4, &sB); |
| 240 | struct s_strmat sC; s_allocate_strmat(n+4, n+4, &sC); |
| 241 | struct s_strmat sD; s_allocate_strmat(n+4, n+4, &sD); |
| 242 | struct s_strmat sE; s_allocate_strmat(n+4, n+4, &sE); |
| 243 | #else |
| 244 | struct s_strmat sA; s_allocate_strmat(n, n, &sA); |
| 245 | struct s_strmat sB; s_allocate_strmat(n, n, &sB); |
| 246 | struct s_strmat sC; s_allocate_strmat(n, n, &sC); |
| 247 | struct s_strmat sD; s_allocate_strmat(n, n, &sD); |
| 248 | struct s_strmat sE; s_allocate_strmat(n, n, &sE); |
| 249 | #endif |
| 250 | struct s_strvec sx; s_allocate_strvec(n, &sx); |
| 251 | struct s_strvec sy; s_allocate_strvec(n, &sy); |
| 252 | struct s_strvec sz; s_allocate_strvec(n, &sz); |
| 253 | |
| 254 | s_cvt_mat2strmat(n, n, A, n, &sA, 0, 0); |
| 255 | s_cvt_mat2strmat(n, n, B, n, &sB, 0, 0); |
| 256 | s_cvt_vec2strvec(n, x, &sx, 0); |
| 257 | |
| 258 | |
| 259 | // create matrix to pivot all the time |
| 260 | // sgemm_nt_libstr(n, n, n, 1.0, &sA, 0, 0, &sA, 0, 0, 1.0, &sB, 0, 0, &sD, 0, 0); |
| 261 | |
| 262 | float *dummy; |
| 263 | |
| 264 | int info; |
| 265 | |
| 266 | /* timing */ |
| 267 | struct timeval tvm1, tv0, tv1, tv2, tv3, tv4, tv5, tv6, tv7, tv8, tv9, tv10, tv11, tv12, tv13, tv14, tv15, tv16; |
| 268 | |
| 269 | /* warm up */ |
| 270 | for(rep=0; rep<nrep; rep++) |
| 271 | { |
| 272 | sgemm_nt_libstr(n, n, n, 1.0, &sA, 0, 0, &sB, 0, 0, 0.0, &sC, 0, 0, &sD, 0, 0); |
| 273 | } |
| 274 | |
| 275 | float alpha = 1.0; |
| 276 | float beta = 0.0; |
| 277 | |
| 278 | gettimeofday(&tv0, NULL); // stop |
| 279 | |
| 280 | gettimeofday(&tv1, NULL); // stop |
| 281 | |
| 282 | for(rep=0; rep<nrep; rep++) |
| 283 | { |
| 284 | // kernel_sgemm_nt_24x4_lib8(n, &alpha, sA.pA, sA.cn, sB.pA, &beta, sD.pA, sD.cn, sD.pA, sD.cn); |
| 285 | // kernel_sgemm_nt_16x4_lib8(n, &alpha, sA.pA, sA.cn, sB.pA, &beta, sD.pA, sD.cn, sD.pA, sD.cn); |
| 286 | // kernel_sgemm_nt_8x8_lib8(n, &alpha, sA.pA, sB.pA, &beta, sD.pA, sD.pA); |
| 287 | // kernel_sgemm_nt_8x4_lib8(n, &alpha, sA.pA, sB.pA, &beta, sD.pA, sD.pA); |
| 288 | // kernel_sgemm_nt_4x8_gen_lib8(n, &alpha, sA.pA, sB.pA, &beta, 0, sD.pA, sD.cn, 0, sD.pA, sD.cn, 0, 4, 0, 8); |
| 289 | // kernel_sgemm_nt_4x8_vs_lib8(n, &alpha, sA.pA, sB.pA, &beta, sD.pA, sD.pA, 4, 8); |
| 290 | // kernel_sgemm_nt_4x8_lib8(n, &alpha, sA.pA, sB.pA, &beta, sD.pA, sD.pA); |
| 291 | // kernel_sgemm_nt_12x4_lib4(n, &alpha, sA.pA, sA.cn, sB.pA, &beta, sD.pA, sD.cn, sD.pA, sD.cn); |
| 292 | // kernel_sgemm_nt_8x4_lib4(n, &alpha, sA.pA, sA.cn, sB.pA, &beta, sD.pA, sD.cn, sD.pA, sD.cn); |
| 293 | // kernel_sgemm_nt_4x4_lib4(n, &alpha, sA.pA, sB.pA, &beta, sD.pA, sD.pA); |
| 294 | // kernel_sgemm_nn_16x4_lib8(n, &alpha, sA.pA, sA.cn, 0, sB.pA, sB.cn, &beta, sD.pA, sD.cn, sD.pA, sD.cn); |
| 295 | // kernel_sgemm_nn_8x8_lib8(n, &alpha, sA.pA, 0, sB.pA, sB.cn, &beta, sD.pA, sD.pA); |
| 296 | // kernel_sgemm_nn_8x4_lib8(n, &alpha, sA.pA, 0, sB.pA, sB.cn, &beta, sD.pA, sD.pA); |
| 297 | |
| 298 | // sgemm_nt_libstr(n, n, n, 1.0, &sA, 0, 0, &sB, 0, 0, 0.0, &sC, 0, 0, &sD, 0, 0); |
| 299 | // sgemm_nn_libstr(n, n, n, 1.0, &sA, 0, 0, &sB, 0, 0, 0.0, &sC, 0, 0, &sD, 0, 0); |
| 300 | // ssyrk_ln_libstr(n, n, 1.0, &sA, 0, 0, &sA, 0, 0, 0.0, &sC, 0, 0, &sD, 0, 0); |
| 301 | // spotrf_l_mn_libstr(n, n, &sB, 0, 0, &sB, 0, 0); |
| 302 | spotrf_l_libstr(n, &sB, 0, 0, &sB, 0, 0); |
| 303 | // sgetr_libstr(n, n, &sA, 0, 0, &sB, 0, 0); |
| 304 | // sgetrf_nopivot_libstr(n, n, &sB, 0, 0, &sB, 0, 0); |
| 305 | // sgetrf_libstr(n, n, &sB, 0, 0, &sB, 0, 0, ipiv); |
| 306 | // strmm_rlnn_libstr(n, n, 1.0, &sA, 0, 0, &sB, 0, 0, &sD, 0, 0); |
| 307 | // strmm_rutn_libstr(n, n, 1.0, &sA, 0, 0, &sB, 0, 0, &sD, 0, 0); |
| 308 | // strsm_llnu_libstr(n, n, 1.0, &sD, 0, 0, &sB, 0, 0, &sB, 0, 0); |
| 309 | // strsm_lunn_libstr(n, n, 1.0, &sD, 0, 0, &sB, 0, 0, &sB, 0, 0); |
| 310 | // strsm_rltn_libstr(n, n, 1.0, &sB, 0, 0, &sD, 0, 0, &sD, 0, 0); |
| 311 | // strsm_rltu_libstr(n, n, 1.0, &sD, 0, 0, &sB, 0, 0, &sB, 0, 0); |
| 312 | // strsm_rutn_libstr(n, n, 1.0, &sD, 0, 0, &sB, 0, 0, &sB, 0, 0); |
| 313 | // sgemv_n_libstr(n, n, 1.0, &sA, 0, 0, &sx, 0, 0.0, &sy, 0, &sz, 0); |
| 314 | // sgemv_t_libstr(n, n, 1.0, &sA, 0, 0, &sx, 0, 0.0, &sy, 0, &sz, 0); |
| 315 | // ssymv_l_libstr(n, n, 1.0, &sA, 0, 0, &sx, 0, 0.0, &sy, 0, &sz, 0); |
| 316 | // sgemv_nt_libstr(n, n, 1.0, 1.0, &sA, 0, 0, &sx, 0, &sx, 0, 0.0, 0.0, &sy, 0, &sy, 0, &sz, 0, &sz, 0); |
| 317 | } |
| 318 | |
| 319 | // d_print_strmat(n, n, &sD, 0, 0); |
| 320 | |
| 321 | gettimeofday(&tv2, NULL); // stop |
| 322 | |
| 323 | for(rep=0; rep<nrep; rep++) |
| 324 | { |
| 325 | #if defined(REF_BLAS_OPENBLAS) || defined(REF_BLAS_NETLIB) || defined(REF_BLAS_MKL) |
| 326 | // sgemm_(&c_n, &c_t, &n, &n, &n, &d_1, A, &n, M, &n, &d_0, C, &n); |
| 327 | // sgemm_(&c_n, &c_n, &n, &n, &n, &d_1, A, &n, M, &n, &d_0, C, &n); |
| 328 | // scopy_(&n2, A, &i_1, B, &i_1); |
| 329 | // ssyrk_(&c_l, &c_n, &n, &n, &d_1, A, &n, &d_0, C, &n); |
| 330 | // strmm_(&c_r, &c_u, &c_t, &c_n, &n, &n, &d_1, A, &n, C, &n); |
| 331 | // spotrf_(&c_l, &n, B2, &n, &info); |
| 332 | // sgetrf_(&n, &n, B2, &n, ipiv, &info); |
| 333 | // strsm_(&c_l, &c_l, &c_n, &c_u, &n, &n, &d_1, B2, &n, B, &n); |
| 334 | // strsm_(&c_l, &c_u, &c_n, &c_n, &n, &n, &d_1, B2, &n, B, &n); |
| 335 | // strtri_(&c_l, &c_n, &n, B2, &n, &info); |
| 336 | // slauum_(&c_l, &n, B, &n, &info); |
| 337 | // sgemv_(&c_n, &n, &n, &d_1, A, &n, x, &i_1, &d_0, y, &i_1); |
| 338 | // sgemv_(&c_t, &n, &n, &d_1, A, &n, x2, &i_1, &d_0, y2, &i_1); |
| 339 | // strmv_(&c_l, &c_n, &c_n, &n, B, &n, x, &i_1); |
| 340 | // strsv_(&c_l, &c_n, &c_n, &n, B, &n, x, &i_1); |
| 341 | // ssymv_(&c_l, &n, &d_1, A, &n, x, &i_1, &d_0, y, &i_1); |
| 342 | |
| 343 | // for(i=0; i<n; i++) |
| 344 | // { |
| 345 | // i_t = n-i; |
| 346 | // scopy_(&i_t, &B[i*(n+1)], &i_1, &C[i*(n+1)], &i_1); |
| 347 | // } |
| 348 | // ssyrk_(&c_l, &c_n, &n, &n, &d_1, A, &n, &d_1, C, &n); |
| 349 | // spotrf_(&c_l, &n, C, &n, &info); |
| 350 | |
| 351 | #endif |
| 352 | |
| 353 | #if defined(REF_BLAS_BLIS) |
| 354 | // sgemm_(&c_n, &c_t, &n77, &n77, &n77, &d_1, A, &n77, B, &n77, &d_0, C, &n77); |
| 355 | // sgemm_(&c_n, &c_n, &n77, &n77, &n77, &d_1, A, &n77, B, &n77, &d_0, C, &n77); |
| 356 | // ssyrk_(&c_l, &c_n, &n77, &n77, &d_1, A, &n77, &d_0, C, &n77); |
| 357 | // strmm_(&c_r, &c_u, &c_t, &c_n, &n77, &n77, &d_1, A, &n77, C, &n77); |
| 358 | // spotrf_(&c_l, &n77, B, &n77, &info); |
| 359 | // strtri_(&c_l, &c_n, &n77, B, &n77, &info); |
| 360 | // slauum_(&c_l, &n77, B, &n77, &info); |
| 361 | #endif |
| 362 | } |
| 363 | |
| 364 | gettimeofday(&tv3, NULL); // stop |
| 365 | |
| 366 | // flops |
| 367 | if(1) |
| 368 | { |
| 369 | |
| 370 | float Gflops_max = flops_max * GHz_max; |
| 371 | |
| 372 | // float flop_operation = 6*16.0*2*n; // kernel 24x4 |
| 373 | // float flop_operation = 4*16.0*2*n; // kernel 16x4 |
| 374 | // float flop_operation = 3*16.0*2*n; // kernel 12x4 |
| 375 | // float flop_operation = 2*16.0*2*n; // kernel 8x4 |
| 376 | // float flop_operation = 1*16.0*2*n; // kernel 4x4 |
| 377 | |
| 378 | // float flop_operation = 2.0*n*n*n; // dgemm |
| 379 | // float flop_operation = 1.0*n*n*n; // dsyrk dtrmm dtrsm |
| 380 | float flop_operation = 1.0/3.0*n*n*n; // dpotrf dtrtri |
| 381 | // float flop_operation = 2.0/3.0*n*n*n; // dgetrf |
| 382 | // float flop_operation = 2.0*n*n; // dgemv dsymv |
| 383 | // float flop_operation = 1.0*n*n; // dtrmv dtrsv |
| 384 | // float flop_operation = 4.0*n*n; // dgemv_nt |
| 385 | // float flop_operation = 3*16.0*2*n; // kernel 12x4 |
| 386 | |
| 387 | // float flop_operation = 4.0/3.0*n*n*n; // dsyrk+dpotrf |
| 388 | |
| 389 | float time_hpmpc = (float) (tv1.tv_sec-tv0.tv_sec)/(nrep+0.0)+(tv1.tv_usec-tv0.tv_usec)/(nrep*1e6); |
| 390 | float time_blasfeo = (float) (tv2.tv_sec-tv1.tv_sec)/(nrep+0.0)+(tv2.tv_usec-tv1.tv_usec)/(nrep*1e6); |
| 391 | float time_blas = (float) (tv3.tv_sec-tv2.tv_sec)/(nrep+0.0)+(tv3.tv_usec-tv2.tv_usec)/(nrep*1e6); |
| 392 | |
| 393 | float Gflops_hpmpc = 1e-9*flop_operation/time_hpmpc; |
| 394 | float Gflops_blasfeo = 1e-9*flop_operation/time_blasfeo; |
| 395 | float Gflops_blas = 1e-9*flop_operation/time_blas; |
| 396 | |
| 397 | |
| 398 | printf("%d\t%7.2f\t%7.2f\t%7.2f\t%7.2f\n", n, Gflops_blasfeo, 100.0*Gflops_blasfeo/Gflops_max, Gflops_blas, 100.0*Gflops_blas/Gflops_max); |
| 399 | // fprintf(f, "%d\t%7.2f\t%7.2f\t%7.2f\t%7.2f\n", n, Gflops_blasfeo, 100.0*Gflops_blasfeo/Gflops_max, Gflops_blas, 100.0*Gflops_blas/Gflops_max); |
| 400 | |
| 401 | } |
| 402 | // memops |
| 403 | else |
| 404 | { |
| 405 | |
| 406 | float Gmemops_max = memops_max * GHz_max; |
| 407 | |
| 408 | float memop_operation = 1.0*n*n; // dgecp |
| 409 | |
| 410 | float time_hpmpc = (float) (tv1.tv_sec-tv0.tv_sec)/(nrep+0.0)+(tv1.tv_usec-tv0.tv_usec)/(nrep*1e6); |
| 411 | float time_blasfeo = (float) (tv2.tv_sec-tv1.tv_sec)/(nrep+0.0)+(tv2.tv_usec-tv1.tv_usec)/(nrep*1e6); |
| 412 | float time_blas = (float) (tv3.tv_sec-tv2.tv_sec)/(nrep+0.0)+(tv3.tv_usec-tv2.tv_usec)/(nrep*1e6); |
| 413 | |
| 414 | float Gmemops_hpmpc = 1e-9*memop_operation/time_hpmpc; |
| 415 | float Gmemops_blasfeo = 1e-9*memop_operation/time_blasfeo; |
| 416 | float Gmemops_blas = 1e-9*memop_operation/time_blas; |
| 417 | |
| 418 | |
| 419 | printf("%d\t%7.2f\t%7.2f\t%7.2f\t%7.2f\n", n, Gmemops_blasfeo, 100.0*Gmemops_blasfeo/Gmemops_max, Gmemops_blas, 100.0*Gmemops_blas/Gmemops_max); |
| 420 | // fprintf(f, "%d\t%7.2f\t%7.2f\t%7.2f\t%7.2f\n", n, Gmemops_blasfeo, 100.0*Gmemops_blasfeo/Gmemops_max, Gmemops_blas, 100.0*Gmemops_blas/Gmemops_max); |
| 421 | |
| 422 | } |
| 423 | |
| 424 | |
| 425 | free(A); |
| 426 | free(B); |
| 427 | free(B2); |
| 428 | free(M); |
| 429 | free(x); |
| 430 | free(y); |
| 431 | free(x2); |
| 432 | free(y2); |
| 433 | free(ipiv); |
| 434 | |
| 435 | s_free_strmat(&sA); |
| 436 | s_free_strmat(&sB); |
| 437 | s_free_strmat(&sC); |
| 438 | s_free_strmat(&sD); |
| 439 | s_free_strmat(&sE); |
| 440 | s_free_strvec(&sx); |
| 441 | s_free_strvec(&sy); |
| 442 | s_free_strvec(&sz); |
| 443 | |
| 444 | } |
| 445 | |
| 446 | printf("\n"); |
| 447 | |
| 448 | // fprintf(f, "];\n"); |
| 449 | // fclose(f); |
| 450 | |
| 451 | return 0; |
| 452 | |
| 453 | } |
| 454 | |