Simulation Core
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

187 lines
13 KiB

  1. ! BSD 2-Clause License
  2. !
  3. ! Copyright (c) 2021-2022, Hewlett Packard Enterprise
  4. ! All rights reserved.
  5. !
  6. ! Redistribution and use in source and binary forms, with or without
  7. ! modification, are permitted provided that the following conditions are met:
  8. !
  9. ! 1. Redistributions of source code must retain the above copyright notice, this
  10. ! list of conditions and the following disclaimer.
  11. !
  12. ! 2. Redistributions in binary form must reproduce the above copyright notice,
  13. ! this list of conditions and the following disclaimer in the documentation
  14. ! and/or other materials provided with the distribution.
  15. !
  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 ARE
  19. ! DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  20. ! 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 USE
  25. ! OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. interface
  27. function get_script_c( c_client, key, key_length, script, script_length) bind(c,name="get_script")
  28. use iso_c_binding, only : c_ptr, c_char, c_size_t
  29. import :: enum_kind
  30. integer(kind=enum_kind) :: get_script_c
  31. type(c_ptr), value, intent(in) :: c_client !< Initialized SmartRedis client
  32. character(kind=c_char), intent(in) :: key(*) !< The key to use to place the script
  33. integer(kind=c_size_t), value, intent(in) :: key_length !< The length of the key c-string, excluding null
  34. type(c_ptr), intent(inout) :: script !< The script as a continuous buffer
  35. integer(kind=c_size_t), intent( out) :: script_length !< Length of the script buffer c-string
  36. end function get_script_c
  37. end interface
  38. interface
  39. function set_script_from_file_c( c_client, key, key_length, device, device_length, &
  40. script_file, script_file_length) bind(c,name="set_script_from_file")
  41. use iso_c_binding, only : c_ptr, c_size_t, c_char
  42. import :: enum_kind
  43. integer(kind=enum_kind) :: set_script_from_file_c
  44. type(c_ptr), value, intent(in) :: c_client !< Initialized SmartRedis client
  45. character(kind=c_char), intent(in) :: key(*) !< The key to use to place the script
  46. integer(kind=c_size_t), value, intent(in) :: key_length !< The length of the key c-string, excluding null
  47. character(kind=c_char), intent(in) :: device(*) !< The name of the device (CPU, GPU, GPU:0, GPU:1...)
  48. integer(kind=c_size_t), value, intent(in) :: device_length !< The length of the device name c-string, excluding
  49. !! null terminating character
  50. character(kind=c_char), intent(in) :: script_file(*) !< The file storing the script
  51. integer(kind=c_size_t), value, intent(in) :: script_file_length !< The length of the file name c-string, excluding
  52. !! null terminating character
  53. end function set_script_from_file_c
  54. end interface
  55. interface
  56. function set_script_from_file_multigpu_c(c_client, key, key_length, script_file, script_file_length, &
  57. first_gpu, num_gpus) bind(c,name="set_script_from_file_multigpu")
  58. use iso_c_binding, only : c_ptr, c_size_t, c_char, c_int
  59. import :: enum_kind
  60. integer(kind=enum_kind) :: set_script_from_file_multigpu_c
  61. type(c_ptr), value, intent(in) :: c_client !< Initialized SmartRedis client
  62. character(kind=c_char), intent(in) :: key(*) !< The key to use to place the script
  63. integer(kind=c_size_t), value, intent(in) :: key_length !< The length of the key c-string, excluding null
  64. character(kind=c_char), intent(in) :: script_file(*) !< The file storing the script
  65. integer(kind=c_size_t), value, intent(in) :: script_file_length !< The length of the file name c-string, excluding
  66. integer(kind=c_int), value, intent(in) :: first_gpu !< ID of the first GPU to set the model on
  67. integer(kind=c_int), value, intent(in) :: num_gpus !< How many GPUs to use in the orchestrator
  68. !! null terminating character
  69. end function set_script_from_file_multigpu_c
  70. end interface
  71. interface
  72. function set_script_c( c_client, key, key_length, device, device_length, script, script_length ) &
  73. bind(c, name="set_script")
  74. use iso_c_binding, only : c_ptr, c_size_t, c_char
  75. import :: enum_kind
  76. integer(kind=enum_kind) :: set_script_c
  77. type(c_ptr), value, intent(in) :: c_client !< Initialized SmartRedis client
  78. character(kind=c_char), intent(in) :: key(*) !< The key to use to place the script
  79. integer(kind=c_size_t), value, intent(in) :: key_length !< The length of the key c-string, excluding null
  80. character(kind=c_char), intent(in) :: device(*) !< The name of the device (CPU, GPU, GPU:0, GPU:1...)
  81. integer(kind=c_size_t), value, intent(in) :: device_length !< The length of the device name c-string, excluding
  82. !! null terminating character
  83. character(kind=c_char), intent(in) :: script(*) !< The file storing the script
  84. integer(kind=c_size_t), value, intent(in) :: script_length !< The length of the file name c-string, excluding
  85. !! null terminating character
  86. end function set_script_c
  87. end interface
  88. interface
  89. function set_script_multigpu_c( c_client, key, key_length, script, script_length, &
  90. first_gpu, num_gpus) bind(c, name="set_script_multigpu")
  91. use iso_c_binding, only : c_ptr, c_size_t, c_char, c_int
  92. import :: enum_kind
  93. integer(kind=enum_kind) :: set_script_multigpu_c
  94. type(c_ptr), value, intent(in) :: c_client !< Initialized SmartRedis client
  95. character(kind=c_char), intent(in) :: key(*) !< The key to use to place the script
  96. integer(kind=c_size_t), value, intent(in) :: key_length !< The length of the key c-string, excluding null
  97. character(kind=c_char), intent(in) :: script(*) !< The file storing the script
  98. integer(kind=c_size_t), value, intent(in) :: script_length !< The length of the file name c-string, excluding
  99. !! null terminating character
  100. integer(kind=c_int), value, intent(in) :: first_gpu !< ID of the first GPU to set the model on
  101. integer(kind=c_int), value, intent(in) :: num_gpus !< How many GPUs to use in the orchestrator
  102. !! null terminating character
  103. end function set_script_multigpu_c
  104. end interface
  105. interface
  106. function run_script_c(c_client, key, key_length, func, func_length, inputs, input_lengths, n_inputs, &
  107. outputs, output_lengths, n_outputs) bind(c, name="run_script")
  108. use iso_c_binding, only : c_ptr, c_size_t, c_char
  109. import :: enum_kind
  110. integer(kind=enum_kind) :: run_script_c
  111. type(c_ptr), value, intent(in) :: c_client !< Initialized SmartRedis client
  112. character(kind=c_char), intent(in) :: key(*) !< The key to use to place the script
  113. integer(kind=c_size_t), value, intent(in) :: key_length !< The length of the key c-string, excluding null
  114. character(kind=c_char), intent(in) :: func(*) !< The name of the function in the script to call
  115. integer(kind=c_size_t), value, intent(in) :: func_length !< The length of the function c-string, excluding
  116. !! null terminating character
  117. type(c_ptr), value, intent(in) :: inputs !< One or more names of script input nodes (TF scripts)
  118. type(c_ptr), value, intent(in) :: input_lengths !< The length of each input name c-string, excluding
  119. !! null terminating character
  120. integer(kind=c_size_t), value, intent(in) :: n_inputs !< The number of inputs
  121. type(c_ptr), value, intent(in) :: outputs !< One or more names of script output nodes
  122. !! (TF scripts)
  123. type(c_ptr), value, intent(in) :: output_lengths !< The length of each output name c-string,
  124. !! excluding null terminating character
  125. integer(kind=c_size_t), value, intent(in) :: n_outputs !< The number of outputs
  126. end function run_script_c
  127. end interface
  128. interface
  129. function run_script_multigpu_c(c_client, key, key_length, func, func_length, inputs, input_lengths, n_inputs, &
  130. outputs, output_lengths, n_outputs, offset, first_gpu, num_gpus) &
  131. bind(c, name="run_script_multigpu")
  132. use iso_c_binding, only : c_ptr, c_size_t, c_char, c_int
  133. import :: enum_kind
  134. integer(kind=enum_kind) :: run_script_multigpu_c
  135. type(c_ptr), value, intent(in) :: c_client !< Initialized SmartRedis client
  136. character(kind=c_char), intent(in) :: key(*) !< The key to use to place the script
  137. integer(kind=c_size_t), value, intent(in) :: key_length !< The length of the key c-string, excluding null
  138. character(kind=c_char), intent(in) :: func(*) !< The name of the function in the script to call
  139. integer(kind=c_size_t), value, intent(in) :: func_length !< The length of the function c-string, excluding
  140. !! null terminating character
  141. type(c_ptr), value, intent(in) :: inputs !< One or more names of script input nodes (TF scripts)
  142. type(c_ptr), value, intent(in) :: input_lengths !< The length of each input name c-string, excluding
  143. !! null terminating character
  144. integer(kind=c_size_t), value, intent(in) :: n_inputs !< The number of inputs
  145. type(c_ptr), value, intent(in) :: outputs !< One or more names of script output nodes
  146. !! (TF scripts)
  147. type(c_ptr), value, intent(in) :: output_lengths !< The length of each output name c-string,
  148. !! excluding null terminating character
  149. integer(kind=c_size_t), value, intent(in) :: n_outputs !< The number of outputs
  150. integer(kind=c_int), value, intent(in) :: offset !< Index of the current image, such as a processor
  151. integer(kind=c_int), value, intent(in) :: first_gpu !< ID of the first GPU to use the model on
  152. integer(kind=c_int), value, intent(in) :: num_gpus !< How many GPUs to use in the orchestrator
  153. end function run_script_multigpu_c
  154. end interface
  155. interface
  156. function delete_script_c(c_client, key, key_length) bind(c, name="delete_script")
  157. use iso_c_binding, only : c_ptr, c_size_t, c_char
  158. import :: enum_kind
  159. integer(kind=enum_kind) :: delete_script_c
  160. type(c_ptr), value, intent(in) :: c_client !< Initialized SmartRedis client
  161. character(kind=c_char), intent(in) :: key(*) !< The key to use to place the script
  162. integer(kind=c_size_t), value, intent(in) :: key_length !< The length of the key c-string, excluding null
  163. end function delete_script_c
  164. end interface
  165. interface
  166. function delete_script_multigpu_c(c_client, key, key_length, first_gpu, num_gpus) &
  167. bind(c, name="delete_script_multigpu")
  168. use iso_c_binding, only : c_ptr, c_size_t, c_char, c_int
  169. import :: enum_kind
  170. integer(kind=enum_kind) :: delete_script_multigpu_c
  171. type(c_ptr), value, intent(in) :: c_client !< Initialized SmartRedis client
  172. character(kind=c_char), intent(in) :: key(*) !< The key to use to place the script_multigpu
  173. integer(kind=c_size_t), value, intent(in) :: key_length !< The length of the key c-string, excluding null
  174. integer(kind=c_int), value, intent(in) :: first_gpu !< ID of the first GPU to use the model on
  175. integer(kind=c_int), value, intent(in) :: num_gpus !< How many GPUs to use in the orchestrator
  176. end function delete_script_multigpu_c
  177. end interface