jlstarpu_task_submit.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2018 Alexis Juven
  4. *
  5. * StarPU 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. * StarPU 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. /*
  17. * jlstarpu_task_submit.c
  18. *
  19. * Created on: 27 juin 2018
  20. * Author: ajuven
  21. */
  22. #include "jlstarpu.h"
  23. struct starpu_codelet * jlstarpu_new_codelet()
  24. {
  25. struct starpu_codelet * output;
  26. TYPE_MALLOC(output, 1);
  27. starpu_codelet_init(output);
  28. return output;
  29. }
  30. #if 0
  31. struct starpu_codelet * jlstarpu_translate_codelet(struct jlstarpu_codelet * const input)
  32. {
  33. struct starpu_codelet * output;
  34. TYPE_MALLOC(output, 1);
  35. starpu_codelet_init(output);
  36. output->where = input->where;
  37. output->cpu_funcs[0] = input->cpu_func;
  38. output->cpu_funcs_name[0] = input->cpu_func_name;
  39. output->cuda_funcs[0] = input->cuda_func;
  40. output->opencl_funcs[0] = input->opencl_func;
  41. output->nbuffers = input->nbuffer;
  42. memcpy(&(output->modes), input->modes, input->nbuffer * sizeof(enum starpu_data_access_mode));
  43. output->model = input->model;
  44. return output;
  45. }
  46. #endif
  47. void jlstarpu_codelet_update(const struct jlstarpu_codelet * const input, struct starpu_codelet * const output)
  48. {
  49. output->where = input->where;
  50. output->color = input->color;
  51. output->cpu_funcs[0] = input->cpu_func;
  52. output->cpu_funcs_name[0] = input->cpu_func_name;
  53. output->cuda_funcs[0] = input->cuda_func;
  54. output->opencl_funcs[0] = input->opencl_func;
  55. output->nbuffers = input->nbuffer;
  56. memcpy(&(output->modes), input->modes, input->nbuffer * sizeof(enum starpu_data_access_mode));
  57. output->model = input->model;
  58. }
  59. #if 0
  60. void jlstarpu_free_codelet(struct starpu_codelet * cl)
  61. {
  62. free(cl);
  63. }
  64. #endif
  65. void jlstarpu_hello() {
  66. fprintf(stderr,"coucou !");
  67. }
  68. #if 0
  69. struct starpu_task * jlstarpu_translate_task(const struct jlstarpu_task * const input)
  70. {
  71. struct starpu_task * output = starpu_task_create();
  72. if (output == NULL){
  73. return NULL;
  74. }
  75. output->cl = input->cl;
  76. memcpy(&(output->handles), input->handles, input->cl->nbuffers * sizeof(starpu_data_handle_t));
  77. output->synchronous = input->synchronous;
  78. return output;
  79. }
  80. #endif
  81. char *starpu_find_function(char *name, char *device) {
  82. return NULL;
  83. }
  84. void jlstarpu_task_update(const struct jlstarpu_task * const input, struct starpu_task * const output)
  85. {
  86. output->cl = input->cl;
  87. memcpy(&(output->handles), input->handles, input->cl->nbuffers * sizeof(starpu_data_handle_t));
  88. output->synchronous = input->synchronous;
  89. output->cl_arg = input->cl_arg;
  90. output->cl_arg_size = input->cl_arg_size;
  91. }
  92. /*
  93. void print_perfmodel(struct starpu_perfmodel * p)
  94. {
  95. printf("Perfmodel at address %p:\n");
  96. printf("\ttype : %u\n", p->type);
  97. printf("\tcost_function : %p\n", p->cost_function);
  98. printf("\tarch_cost_function : %p\n", p->arch_cost_function);
  99. printf("\tsize_base : %p\n", p->size_base);
  100. printf("\tfootprint : %p\n", p->footprint);
  101. printf("\tsymbol : %s\n", p->symbol);
  102. printf("\tis_loaded : %u\n", p->is_loaded);
  103. printf("\tbenchmarking : %u\n", p->benchmarking);
  104. printf("\tis_init : %u\n", p->is_init);
  105. printf("\tparameters : %p\n", p->parameters);
  106. printf("\tparameters_names : %p\n", p->parameters_names);
  107. printf("\tnparameters : %u\n", p->nparameters);
  108. printf("\tcombinations : %p\n", p->combinations);
  109. printf("\tncombinations : %u\n", p->ncombinations);
  110. printf("\tstate : %p\n", p->state);
  111. }
  112. */
  113. #if 0
  114. /*
  115. * TODO : free memory
  116. */
  117. int jlstarpu_task_submit(const struct jlstarpu_task * const jl_task)
  118. {
  119. DEBUG_PRINT("Inside C wrapper");
  120. struct starpu_task * task;
  121. int ret_code;
  122. DEBUG_PRINT("Translating task...");
  123. task = jlstarpu_translate_task(jl_task);
  124. if (task == NULL){
  125. fprintf(stderr, "Error while creating the task.\n");
  126. return EXIT_FAILURE;
  127. }
  128. DEBUG_PRINT("Task translated");
  129. DEBUG_PRINT("Submitting task to StarPU...");
  130. ret_code = starpu_task_submit(task);
  131. DEBUG_PRINT("starpu_task_submit has returned");
  132. if (ret_code != 0){
  133. fprintf(stderr, "Error while submitting task.\n");
  134. return ret_code;
  135. }
  136. DEBUG_PRINT("Done");
  137. DEBUG_PRINT("END OF STARPU FUNCTION");
  138. return ret_code;
  139. }
  140. #endif
  141. #define JLSTARPU_UPDATE_FUNC(type, field)\
  142. \
  143. void jlstarpu_##type##_update_##field(const struct jlstarpu_##type * const input, struct starpu_##type * const output)\
  144. {\
  145. output->field = input->field;\
  146. }