cholesky_and_lu.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #include "cholesky/cholesky.h"
  2. #include "lu/lu_example_float.c"
  3. #include <pthread.h>
  4. typedef struct {
  5. int argc;
  6. char **argv;
  7. } params;
  8. #define NSAMPLES 10
  9. struct starpu_sched_ctx sched_ctx;
  10. struct starpu_sched_ctx sched_ctx2;
  11. void* func_cholesky(void *val){
  12. params *p = (params*)val;
  13. int procs[] = {1, 2, 3};
  14. starpu_create_sched_ctx(&sched_ctx, "heft", procs, 3, "cholesky");
  15. int i;
  16. double *flops = (double*)malloc(sizeof(double));
  17. (*flops) = 0;
  18. for(i = 0; i < NSAMPLES; i++)
  19. {
  20. (*flops) += run_cholesky_implicit(&sched_ctx, p->argc, p->argv);
  21. }
  22. (*flops) /= NSAMPLES;
  23. return (void*)flops;
  24. }
  25. void* func_cholesky2(void *val){
  26. params *p = (params*)val;
  27. int procs[] = {0, 4, 5, 6, 7, 8, 9, 10, 11};
  28. starpu_create_sched_ctx(&sched_ctx2, "heft", procs, 9, "cholesky");
  29. int i;
  30. double *flops = (double*)malloc(sizeof(double));
  31. (*flops) = 0;
  32. for(i = 0; i < NSAMPLES; i++)
  33. {
  34. (*flops) += run_cholesky_implicit(&sched_ctx2, p->argc, p->argv);
  35. }
  36. (*flops) /= NSAMPLES;
  37. return (void*)flops;
  38. }
  39. void* func_cholesky3(void *val){
  40. params *p = (params*)val;
  41. int i;
  42. double *flops = (double*)malloc(sizeof(double));
  43. (*flops) = 0;
  44. for(i = 0; i < NSAMPLES; i++)
  45. {
  46. (*flops) += run_cholesky_implicit_all_machine(p->argc, p->argv);
  47. }
  48. (*flops) /= NSAMPLES;
  49. return (void*)flops;
  50. }
  51. void* func_lu(void *val){
  52. params *p = (params*)val;
  53. int procs2[] = {0, 4, 5, 6, 7, 8, 9, 10, 11};
  54. starpu_create_sched_ctx(&sched_ctx2, "heft", procs2, 9, "lu");
  55. int i;
  56. double *flops = (double*)malloc(sizeof(double));
  57. (*flops) = 0;
  58. for(i = 0; i < NSAMPLES; i++)
  59. {
  60. printf("%d ", i);
  61. (*flops) += run_lu(&sched_ctx2, p->argc, p->argv);
  62. }
  63. (*flops) /= NSAMPLES;
  64. return (void*)flops;
  65. }
  66. int main(int argc, char **argv)
  67. {
  68. params p;
  69. p.argc = argc;
  70. p.argv = argv;
  71. starpu_init(NULL);
  72. starpu_helper_cublas_init();
  73. pthread_t tid[2];
  74. pthread_create(&tid[0], NULL, (void*)func_cholesky, (void*)&p);
  75. pthread_create(&tid[1], NULL, (void*)func_cholesky2, (void*)&p);
  76. void *gflops_cholesky1;
  77. void *gflops_cholesky2;
  78. // void *gflops_lu = func_lu(&p);
  79. pthread_join(tid[0], &gflops_cholesky1);
  80. pthread_join(tid[1], &gflops_cholesky2);
  81. starpu_helper_cublas_shutdown();
  82. starpu_shutdown();
  83. starpu_init(NULL);
  84. starpu_helper_cublas_init();
  85. void *gflops_cholesky3 = func_cholesky3(&p);
  86. starpu_helper_cublas_shutdown();
  87. starpu_shutdown();
  88. printf("%2.2f %2.2f %2.2f\n", *((double*)gflops_cholesky1), *((double*)gflops_cholesky2), *((double*)gflops_cholesky3));
  89. return 0;
  90. }