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.

min.c 3.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /***************************************************************************
  2. Copyright (c) 2016, 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. #include "bench.h"
  28. #undef NAMIN
  29. #ifndef COMPLEX
  30. #ifdef DOUBLE
  31. #define NAMIN BLASFUNC(dmin)
  32. #else
  33. #define NAMIN BLASFUNC(smin)
  34. #endif
  35. #endif
  36. int main(int argc, char *argv[]){
  37. FLOAT *x;
  38. blasint m, i;
  39. blasint inc_x=1;
  40. int loops = 1;
  41. int l;
  42. char *p;
  43. int from = 1;
  44. int to = 200;
  45. int step = 1;
  46. double time1,timeg;
  47. argc--;argv++;
  48. if (argc > 0) { from = atol(*argv); argc--; argv++;}
  49. if (argc > 0) { to = MAX(atol(*argv), from); argc--; argv++;}
  50. if (argc > 0) { step = atol(*argv); argc--; argv++;}
  51. if ((p = getenv("OPENBLAS_LOOPS"))) loops = atoi(p);
  52. if ((p = getenv("OPENBLAS_INCX"))) inc_x = atoi(p);
  53. fprintf(stderr, "From : %3d To : %3d Step = %3d Inc_x = %d Loops = %d\n", from, to, step,inc_x,loops);
  54. if (( x = (FLOAT *)malloc(sizeof(FLOAT) * to * abs(inc_x) * COMPSIZE)) == NULL){
  55. fprintf(stderr,"Out of Memory!!\n");exit(1);
  56. }
  57. #ifdef __linux
  58. srandom(getpid());
  59. #endif
  60. fprintf(stderr, " SIZE Flops\n");
  61. for(m = from; m <= to; m += step)
  62. {
  63. timeg=0;
  64. fprintf(stderr, " %6d : ", (int)m);
  65. for (l=0; l<loops; l++)
  66. {
  67. for(i = 0; i < m * COMPSIZE * abs(inc_x); i++){
  68. x[i] = ((FLOAT) rand() / (FLOAT) RAND_MAX) - 0.5;
  69. }
  70. begin();
  71. NAMIN (&m, x, &inc_x);
  72. end();
  73. time1 = getsec();
  74. timeg += time1;
  75. }
  76. timeg /= loops;
  77. fprintf(stderr,
  78. " %10.2f MFlops %10.6f sec\n",
  79. COMPSIZE * sizeof(FLOAT) * 1. * (double)m / timeg * 1.e-6, timeg);
  80. }
  81. return 0;
  82. }
  83. // void main(int argc, char *argv[]) __attribute__((weak, alias("MAIN__")));