starpu-blas-wrapper.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * StarPU
  3. * Copyright (C) INRIA 2008-2009 (see AUTHORS file)
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License as published by
  7. * the Free Software Foundation; either version 2.1 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. *
  14. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  15. */
  16. #ifndef __STARPU_BLAS_WRAPPER_H__
  17. #define __STARPU_BLAS_WRAPPER_H__
  18. #include "generated_model.h"
  19. #define OVERHEAD 150000.0
  20. static double transfer_time_dtoh(unsigned size)
  21. {
  22. double latency = 0.0;
  23. double bandwith = 0.0;
  24. return latency + size*bandwith;
  25. }
  26. static double transfer_time_htod(unsigned size)
  27. {
  28. double latency = 0.0;
  29. double bandwith = 0.0;
  30. return latency + size*bandwith;
  31. }
  32. /*GEMM CPU */
  33. #define PERF_GEMM_CPU(i,j,k) (GEMM_CPU_A*(double)(i)*(double)(j)*(double)(k)+GEMM_CPU_B*(double)(i)*(double)(j)+GEMM_CPU_C*(double)(j)*(double)(k)+GEMM_CPU_D*(double)(i)+GEMM_CPU_E*(double)(j)+GEMM_CPU_F)
  34. static double starpu_compute_contrib_compact_cpu_cost(starpu_buffer_descr *descr)
  35. {
  36. unsigned nx0, ny0, ny2;
  37. nx0 = descr[0].handle->interface->blas.nx;
  38. ny0 = descr[0].handle->interface->blas.ny;
  39. ny2 = descr[2].handle->interface->blas.ny;
  40. return PERF_GEMM_CPU(nx0-ny0, ny2, ny0);
  41. }
  42. /*GEMM GPU */
  43. #define PERF_GEMM_GPU(i,j,k) (GEMM_GPU_A*(double)(i)*(double)(j)*(double)(k)+GEMM_GPU_B*(double)(i)*(double)(j)+GEMM_GPU_C*(double)(j)*(double)(k)+GEMM_GPU_D*(double)(i)+GEMM_GPU_E*(double)(j)+GEMM_GPU_F)
  44. static double starpu_compute_contrib_compact_cuda_cost(starpu_buffer_descr *descr)
  45. {
  46. unsigned nx0, ny0, ny2;
  47. nx0 = descr[0].handle->interface->blas.nx;
  48. ny0 = descr[0].handle->interface->blas.ny;
  49. ny2 = descr[2].handle->interface->blas.ny;
  50. return PERF_GEMM_GPU(nx0-ny0, ny2, ny0) + OVERHEAD;
  51. }
  52. /*TRSM CPU */
  53. #define PERF_TRSM_GPU(i,j) (TRSM_GPU_A*(double)(i)*(double)(i)*(double)(j)+TRSM_GPU_B*(double)(i)+TRSM_GPU_C)
  54. static double starpu_cblk_strsm_cuda_cost(starpu_buffer_descr *descr)
  55. {
  56. unsigned nx, ny;
  57. nx = descr[0].handle->interface->blas.nx;
  58. ny = descr[0].handle->interface->blas.ny;
  59. return PERF_TRSM_GPU(nx-ny, ny) + OVERHEAD;
  60. }
  61. /*TRSM CPU */
  62. #define PERF_TRSM_CPU(i,j) (TRSM_CPU_A*(double)(i)*(double)(i)*(double)(j)+TRSM_CPU_B*(double)(i)+TRSM_CPU_C)
  63. static double starpu_cblk_strsm_cpu_cost(starpu_buffer_descr *descr)
  64. {
  65. unsigned nx, ny;
  66. nx = descr[0].handle->interface->blas.nx;
  67. ny = descr[0].handle->interface->blas.ny;
  68. return PERF_TRSM_CPU(nx-ny, ny);
  69. }
  70. void STARPU_INIT(void);
  71. void STARPU_TERMINATE(void);
  72. void STARPU_SGEMM (const char *transa, const char *transb, const int m,
  73. const int n, const int k, const float alpha,
  74. const float *A, const int lda, const float *B,
  75. const int ldb, const float beta, float *C, const int ldc);
  76. void STARPU_STRSM (const char *side, const char *uplo, const char *transa,
  77. const char *diag, const int m, const int n,
  78. const float alpha, const float *A, const int lda,
  79. float *B, const int ldb);
  80. #endif // __STARPU_BLAS_WRAPPER_H__