offload_table.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. /*
  2. Copyright (c) 2014-2016 Intel Corporation. All Rights Reserved.
  3. Redistribution and use in source and binary forms, with or without
  4. modification, are permitted provided that the following conditions
  5. are met:
  6. * Redistributions of source code must retain the above copyright
  7. notice, this list of conditions and the following disclaimer.
  8. * Redistributions in binary form must reproduce the above copyright
  9. notice, this list of conditions and the following disclaimer in the
  10. documentation and/or other materials provided with the distribution.
  11. * Neither the name of Intel Corporation nor the names of its
  12. contributors may be used to endorse or promote products derived
  13. from this software without specific prior written permission.
  14. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  15. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  16. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  17. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  18. HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  19. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  20. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  21. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  22. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  23. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  24. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. */
  26. #include "offload_table.h"
  27. #include "offload_common.h"
  28. // Offload Library versioning
  29. // We initialize version to OFFLOAD_VERSION_16
  30. // 15.0 application downgrades this to 1500 for MYO to use the older version.
  31. // 15.0 pragma works without needing version-specific code.
  32. // 16.0-U2 added a call from ofldbegin.cpp to set the version explicitly.
  33. // Pre-16.0-U2 application will find pre-initialized version number as 1600.
  34. // Post 16.0-U2 application will set its own version explicitly.
  35. int offload_version = OFFLOAD_VERSION_16;
  36. int offload_version_count = 0;
  37. #if !HOST_LIBRARY
  38. // Predefined offload entries
  39. extern void omp_set_num_threads_lrb(void*);
  40. extern void omp_get_max_threads_lrb(void*);
  41. extern void omp_get_num_procs_lrb(void*);
  42. extern void omp_set_dynamic_lrb(void*);
  43. extern void omp_get_dynamic_lrb(void*);
  44. extern void omp_set_nested_lrb(void*);
  45. extern void omp_get_nested_lrb(void*);
  46. extern void omp_set_schedule_lrb(void*);
  47. extern void omp_get_schedule_lrb(void*);
  48. extern void omp_init_lock_lrb(void*);
  49. extern void omp_destroy_lock_lrb(void*);
  50. extern void omp_set_lock_lrb(void*);
  51. extern void omp_unset_lock_lrb(void*);
  52. extern void omp_test_lock_lrb(void*);
  53. extern void omp_init_nest_lock_lrb(void*);
  54. extern void omp_destroy_nest_lock_lrb(void*);
  55. extern void omp_set_nest_lock_lrb(void*);
  56. extern void omp_unset_nest_lock_lrb(void*);
  57. extern void omp_test_nest_lock_lrb(void*);
  58. // OpenMP 4.5 APIs
  59. extern void omp_target_alloc_target(void*);
  60. extern void omp_target_free_target(void*);
  61. extern void omp_target_memcpy_target(void*);
  62. extern void omp_target_memcpy_rect_target(void*);
  63. // Predefined entries on the target side
  64. static FuncTable::Entry predefined_entries[] = {
  65. "omp_set_num_threads_target",
  66. (void*) &omp_set_num_threads_lrb,
  67. "omp_get_max_threads_target",
  68. (void*) &omp_get_max_threads_lrb,
  69. "omp_get_num_procs_target",
  70. (void*) &omp_get_num_procs_lrb,
  71. "omp_set_dynamic_target",
  72. (void*) &omp_set_dynamic_lrb,
  73. "omp_get_dynamic_target",
  74. (void*) &omp_get_dynamic_lrb,
  75. "omp_set_nested_target",
  76. (void*) &omp_set_nested_lrb,
  77. "omp_get_nested_target",
  78. (void*) &omp_get_nested_lrb,
  79. "omp_set_schedule_target",
  80. (void*) &omp_set_schedule_lrb,
  81. "omp_get_schedule_target",
  82. (void*) &omp_get_schedule_lrb,
  83. "omp_init_lock_target",
  84. (void*) &omp_init_lock_lrb,
  85. "omp_destroy_lock_target",
  86. (void*) &omp_destroy_lock_lrb,
  87. "omp_set_lock_target",
  88. (void*) &omp_set_lock_lrb,
  89. "omp_unset_lock_target",
  90. (void*) &omp_unset_lock_lrb,
  91. "omp_test_lock_target",
  92. (void*) &omp_test_lock_lrb,
  93. "omp_init_nest_lock_target",
  94. (void*) &omp_init_nest_lock_lrb,
  95. "omp_destroy_nest_lock_target",
  96. (void*) &omp_destroy_nest_lock_lrb,
  97. "omp_set_nest_lock_target",
  98. (void*) &omp_set_nest_lock_lrb,
  99. "omp_unset_nest_lock_target",
  100. (void*) &omp_unset_nest_lock_lrb,
  101. "omp_test_nest_lock_target",
  102. (void*) &omp_test_nest_lock_lrb,
  103. "omp_target_alloc_target",
  104. (void*) &omp_target_alloc_target,
  105. "omp_target_free_target",
  106. (void*) &omp_target_free_target,
  107. "omp_target_memcpy_target",
  108. (void*) &omp_target_memcpy_target,
  109. "omp_target_memcpy_rect_target",
  110. (void*) &omp_target_memcpy_rect_target,
  111. (const char*) -1,
  112. (void*) -1
  113. };
  114. static FuncList::Node predefined_table = {
  115. { predefined_entries, -1 },
  116. 0, 0
  117. };
  118. // Entry table
  119. FuncList __offload_entries(&predefined_table);
  120. #else
  121. FuncList __offload_entries;
  122. #endif // !HOST_LIBRARY
  123. extern "C" {
  124. // Set library version
  125. void __offload_set_version(int v)
  126. {
  127. offload_version_count++;
  128. if (offload_version_count == 1)
  129. {
  130. offload_version = v;
  131. }
  132. else
  133. {
  134. // Mix of versions is not supported
  135. if (v != offload_version)
  136. {
  137. LIBOFFLOAD_ERROR(c_mixed_versions);
  138. exit(1);
  139. }
  140. }
  141. }
  142. } // extern "C"
  143. // Function table. No predefined entries.
  144. FuncList __offload_funcs;
  145. // Var table
  146. VarList __offload_vars;
  147. // Given the function name returns the associtated function pointer
  148. const void* FuncList::find_addr(const char *name)
  149. {
  150. const void* func = 0;
  151. m_lock.lock();
  152. for (Node *n = m_head; n != 0; n = n->next) {
  153. for (const Table::Entry *e = n->table.entries;
  154. e->name != (const char*) -1; e++) {
  155. if (e->name != 0 && strcmp(e->name, name) == 0) {
  156. func = e->func;
  157. break;
  158. }
  159. }
  160. }
  161. m_lock.unlock();
  162. return func;
  163. }
  164. // Given the function pointer returns the associtated function name
  165. const char* FuncList::find_name(const void *func)
  166. {
  167. const char* name = 0;
  168. m_lock.lock();
  169. for (Node *n = m_head; n != 0; n = n->next) {
  170. for (const Table::Entry *e = n->table.entries;
  171. e->name != (const char*) -1; e++) {
  172. if (e->func == func) {
  173. name = e->name;
  174. break;
  175. }
  176. }
  177. }
  178. m_lock.unlock();
  179. return name;
  180. }
  181. // Returns max name length from all tables
  182. int64_t FuncList::max_name_length(void)
  183. {
  184. if (m_max_name_len < 0) {
  185. m_lock.lock();
  186. m_max_name_len = 0;
  187. for (Node *n = m_head; n != 0; n = n->next) {
  188. if (n->table.max_name_len < 0) {
  189. n->table.max_name_len = 0;
  190. // calculate max name length in a single table
  191. for (const Table::Entry *e = n->table.entries;
  192. e->name != (const char*) -1; e++) {
  193. if (e->name != 0) {
  194. size_t len = strlen(e->name) + 1;
  195. if (n->table.max_name_len < len) {
  196. n->table.max_name_len = len;
  197. }
  198. }
  199. }
  200. }
  201. // select max from all tables
  202. if (m_max_name_len < n->table.max_name_len) {
  203. m_max_name_len = n->table.max_name_len;
  204. }
  205. }
  206. m_lock.unlock();
  207. }
  208. return m_max_name_len;
  209. }
  210. // Debugging dump
  211. void FuncList::dump(void)
  212. {
  213. OFFLOAD_DEBUG_TRACE(2, "Function table:\n");
  214. m_lock.lock();
  215. for (Node *n = m_head; n != 0; n = n->next) {
  216. for (const Table::Entry *e = n->table.entries;
  217. e->name != (const char*) -1; e++) {
  218. if (e->name != 0) {
  219. OFFLOAD_DEBUG_TRACE(2, "%p %s\n", e->func, e->name);
  220. }
  221. }
  222. }
  223. m_lock.unlock();
  224. }
  225. // Debugging dump
  226. void VarList::dump(void)
  227. {
  228. OFFLOAD_DEBUG_TRACE(2, "Var table:\n");
  229. m_lock.lock();
  230. for (Node *n = m_head; n != 0; n = n->next) {
  231. for (const Table::Entry *e = n->table.entries;
  232. e->name != (const char*) -1; e++) {
  233. if (e->name != 0) {
  234. #if HOST_LIBRARY
  235. OFFLOAD_DEBUG_TRACE(2, "%s %p %ld\n", e->name, e->addr,
  236. e->size);
  237. #else // HOST_LIBRARY
  238. OFFLOAD_DEBUG_TRACE(2, "%s %p\n", e->name, e->addr);
  239. #endif // HOST_LIBRARY
  240. }
  241. }
  242. }
  243. m_lock.unlock();
  244. }
  245. //
  246. int64_t VarList::table_size(int64_t &nelems)
  247. {
  248. int64_t length = 0;
  249. nelems = 0;
  250. // calculate string table size and number of elements
  251. for (Node *n = m_head; n != 0; n = n->next) {
  252. for (const Table::Entry *e = n->table.entries;
  253. e->name != (const char*) -1; e++) {
  254. if (e->name != 0) {
  255. length += strlen(e->name) + 1;
  256. nelems++;
  257. }
  258. }
  259. }
  260. return nelems * sizeof(BufEntry) + length;
  261. }
  262. // copy table to the gven buffer
  263. void VarList::table_copy(void *buf, int64_t nelems)
  264. {
  265. BufEntry* elems = static_cast<BufEntry*>(buf);
  266. char* names = reinterpret_cast<char*>(elems + nelems);
  267. // copy entries to buffer
  268. for (Node *n = m_head; n != 0; n = n->next) {
  269. for (const Table::Entry *e = n->table.entries;
  270. e->name != (const char*) -1; e++) {
  271. if (e->name != 0) {
  272. // name field contains offset to the name from the beginning
  273. // of the buffer
  274. elems->name = names - static_cast<char*>(buf);
  275. elems->addr = reinterpret_cast<intptr_t>(e->addr);
  276. // copy name to string table
  277. const char *name = e->name;
  278. while ((*names++ = *name++) != '\0');
  279. elems++;
  280. }
  281. }
  282. }
  283. }
  284. // patch name offsets in a buffer
  285. void VarList::table_patch_names(void *buf, int64_t nelems)
  286. {
  287. BufEntry* elems = static_cast<BufEntry*>(buf);
  288. for (int i = 0; i < nelems; i++) {
  289. elems[i].name += reinterpret_cast<intptr_t>(buf);
  290. }
  291. }
  292. #if HOST_LIBRARY
  293. // 16.0 and earlier compilers used the following VarTable
  294. struct OldVarTable {
  295. const char* name;
  296. void* addr;
  297. // uint64_t var_alloc_type missing in 16.0 and earlier
  298. uint64_t size;
  299. };
  300. static void convert_OldVarTable_to_NewVarTable(VarList::Node *vt_start)
  301. {
  302. int table_size = 0;
  303. char * new_var_table;
  304. OldVarTable *old_var_table;
  305. OFFLOAD_DEBUG_TRACE(2,
  306. "Converting old var table to new var table to support backward compatiblity\n");
  307. // Calculate size of memory to be malloced
  308. old_var_table = (OldVarTable *) vt_start->table.entries;
  309. while (old_var_table->name != (const char*) -1) {
  310. table_size++;
  311. old_var_table++;
  312. }
  313. if (table_size != 0) {
  314. // Add 1 to table_size for end of table signature
  315. VarTable::Entry *new_var_table =
  316. new VarTable::Entry[table_size+1];
  317. if (new_var_table == NULL)
  318. LIBOFFLOAD_ERROR(c_malloc);
  319. old_var_table = (OldVarTable *) vt_start->table.entries;
  320. // Update VarList with new table
  321. vt_start->table.entries = new_var_table;
  322. // Fix up the new table value from old table
  323. for (int i=0; i< table_size; i++) {
  324. new_var_table->name = old_var_table->name;
  325. new_var_table->addr = old_var_table->addr;
  326. new_var_table->size = old_var_table->size;
  327. // Assign value of 0 for the missing field.
  328. // Implying it is neither IMPLICIT or LINK variable as
  329. // they were not supported in earlier compilers
  330. new_var_table->var_alloc_type = 0;
  331. old_var_table++;
  332. new_var_table++;
  333. }
  334. new_var_table->name = (const char *)-1;
  335. }
  336. }
  337. #endif //HOST_LIBRARY
  338. // Adds given list element to the global lookup table list
  339. extern "C" void __offload_register_tables(
  340. FuncList::Node *entry_table,
  341. FuncList::Node *func_table,
  342. VarList::Node *var_table
  343. )
  344. {
  345. OFFLOAD_DEBUG_TRACE(2, "Registering offload function entry table %p\n",
  346. entry_table);
  347. __offload_entries.add_table(entry_table);
  348. OFFLOAD_DEBUG_TRACE(2, "Registering function table %p\n", func_table);
  349. __offload_funcs.add_table(func_table);
  350. OFFLOAD_DEBUG_TRACE(2, "Registering var table %p\n", var_table);
  351. // Compiler earlier than 17.0 used a different var_table.
  352. // Convert the old table to new var_table format.
  353. // Only the host table for LINUX has changed.
  354. #ifndef TARGET_WINNT
  355. #if HOST_LIBRARY
  356. if (offload_version < OFFLOAD_VERSION_17) {
  357. convert_OldVarTable_to_NewVarTable(var_table);
  358. }
  359. #endif
  360. #endif
  361. __offload_vars.add_table(var_table);
  362. }
  363. // Removes given list element from the global lookup table list
  364. extern "C" void __offload_unregister_tables(
  365. FuncList::Node *entry_table,
  366. FuncList::Node *func_table,
  367. VarList::Node *var_table
  368. )
  369. {
  370. OFFLOAD_DEBUG_TRACE(2, "Unregistering offload function entry table %p\n",
  371. entry_table);
  372. __offload_entries.remove_table(entry_table);
  373. OFFLOAD_DEBUG_TRACE(2, "Unregistering function table %p\n", func_table);
  374. __offload_funcs.remove_table(func_table);
  375. OFFLOAD_DEBUG_TRACE(2, "Unregistering var table %p\n", var_table);
  376. #ifndef TARGET_WINNT
  377. #if HOST_LIBRARY
  378. if (offload_version < OFFLOAD_VERSION_17) {
  379. // Free the malloced var_table created for backward compatiblity
  380. delete var_table->table.entries;
  381. }
  382. #endif
  383. #endif
  384. __offload_vars.remove_table(var_table);
  385. }
  386. #ifdef MYO_SUPPORT
  387. MYOVarTableList __offload_myo_var_tables;
  388. MYOVarTableList __offload_myo_vtable_tables;
  389. MYOFuncTableList __offload_myo_func_tables;
  390. MYOInitTableList __offload_myo_init_tables;
  391. // Debugging dump
  392. void MYOVarTableList::dump(void)
  393. {
  394. OFFLOAD_DEBUG_TRACE(2, "MYO Var tables:\n");
  395. m_lock.lock();
  396. for (Node *n = m_head; n != 0; n = n->next) {
  397. OFFLOAD_DEBUG_TRACE(2, " MYO Var table:\n");
  398. for (const Table::Entry *e = n->table.entries;
  399. e->varName != MYO_TABLE_END_MARKER(); e++) {
  400. #ifdef TARGET_WINNT
  401. if (e->varName == 0) {
  402. continue;
  403. }
  404. #endif // TARGET_WINNT
  405. OFFLOAD_DEBUG_TRACE(2, " %s %p\n",
  406. e->varName, e->sharedAddr);
  407. }
  408. }
  409. m_lock.unlock();
  410. }
  411. // check if any shared variables
  412. bool MYOVarTableList::is_empty()
  413. {
  414. OFFLOAD_DEBUG_TRACE(3, "Are MYO Var tables empty?\n");
  415. m_lock.lock();
  416. for (Node *n = m_head; n != 0; n = n->next) {
  417. for (const Table::Entry *e = n->table.entries;
  418. e->varName != MYO_TABLE_END_MARKER(); e++) {
  419. #ifdef TARGET_WINNT
  420. if (e->varName == 0) {
  421. continue;
  422. }
  423. #endif // TARGET_WINNT
  424. m_lock.unlock();
  425. OFFLOAD_DEBUG_TRACE(3, "No\n");
  426. return false;
  427. }
  428. }
  429. m_lock.unlock();
  430. OFFLOAD_DEBUG_TRACE(3, "Yes\n");
  431. return true;
  432. }
  433. void MYOFuncTableList::dump(void)
  434. {
  435. OFFLOAD_DEBUG_TRACE(2, "MYO Func tables:\n");
  436. m_lock.lock();
  437. for (Node *n = m_head; n != 0; n = n->next) {
  438. OFFLOAD_DEBUG_TRACE(2, " MYO Func table:\n");
  439. for (const Table::Entry *e = n->table.entries;
  440. e->funcName != MYO_TABLE_END_MARKER(); e++) {
  441. #ifdef TARGET_WINNT
  442. if (e->funcName == 0) {
  443. continue;
  444. }
  445. #endif // TARGET_WINNT
  446. #if HOST_LIBRARY
  447. OFFLOAD_DEBUG_TRACE(2, " %s %p %p\n",
  448. e->funcName, e->funcAddr, e->localThunkAddr);
  449. #else // HOST_LIBRARY
  450. OFFLOAD_DEBUG_TRACE(2, " %s %p %p %p\n",
  451. e->funcName, e->funcAddr, e->wrapFuncAddr, e->localThunkAddr);
  452. #endif // HOST_LIBRARY
  453. }
  454. }
  455. m_lock.unlock();
  456. }
  457. // check if any shared functions
  458. bool MYOFuncTableList::is_empty()
  459. {
  460. OFFLOAD_DEBUG_TRACE(3, "Are MYO Func tables empty?\n");
  461. m_lock.lock();
  462. for (Node *n = m_head; n != 0; n = n->next) {
  463. int count = 0;
  464. for (const Table::Entry *e = n->table.entries;
  465. e->funcName != MYO_TABLE_END_MARKER(); e++) {
  466. #ifdef TARGET_WINNT
  467. if (e->funcName == 0) {
  468. continue;
  469. }
  470. #endif // TARGET_WINNT
  471. count++;
  472. if (count > 1) {
  473. m_lock.unlock();
  474. OFFLOAD_DEBUG_TRACE(3, "No\n");
  475. return false;
  476. }
  477. }
  478. }
  479. m_lock.unlock();
  480. OFFLOAD_DEBUG_TRACE(3, "Yes\n");
  481. return true;
  482. }
  483. void MYOInitTableList::dump(void)
  484. {
  485. OFFLOAD_DEBUG_TRACE(2, "MYO Init tables:\n");
  486. m_lock.lock();
  487. for (Node *n = m_head; n != 0; n = n->next) {
  488. OFFLOAD_DEBUG_TRACE(2, " MYO Init table:\n");
  489. for (const Table::Entry *e = n->table.entries;
  490. #ifdef TARGET_WINNT
  491. e->funcName != MYO_TABLE_END_MARKER(); e++) {
  492. if (e->funcName == 0) {
  493. continue;
  494. }
  495. OFFLOAD_DEBUG_TRACE(2, " %s %p\n", e->funcName, e->func);
  496. #else // TARGET_WINNT
  497. e->func != 0; e++) {
  498. OFFLOAD_DEBUG_TRACE(2, " %p\n", e->func);
  499. #endif // TARGET_WINNT
  500. }
  501. }
  502. m_lock.unlock();
  503. }
  504. // check if any shared functions
  505. bool MYOInitTableList::is_empty()
  506. {
  507. OFFLOAD_DEBUG_TRACE(3, "Are MYO Init tables empty?\n");
  508. m_lock.lock();
  509. for (Node *n = m_head; n != 0; n = n->next) {
  510. for (const Table::Entry *e = n->table.entries;
  511. #ifdef TARGET_WINNT
  512. e->funcName != MYO_TABLE_END_MARKER(); e++) {
  513. if (e->funcName == 0) {
  514. continue;
  515. }
  516. m_lock.unlock();
  517. OFFLOAD_DEBUG_TRACE(3, "No\n");
  518. return false;
  519. #else // TARGET_WINNT
  520. e->func != 0; e++) {
  521. #endif // TARGET_WINNT
  522. }
  523. }
  524. m_lock.unlock();
  525. OFFLOAD_DEBUG_TRACE(3, "Yes\n");
  526. return true;
  527. }
  528. extern "C" void __offload_myoRegisterTables1(
  529. MYOInitTableList::Node *init_table,
  530. MYOVarTableList::Node *shared_table,
  531. MYOVarTableList::Node *shared_vtable,
  532. MYOFuncTableList::Node *fptr_table
  533. )
  534. {
  535. OFFLOAD_DEBUG_TRACE(2, "Registering MYO shared var table %p\n",
  536. shared_table);
  537. __offload_myo_var_tables.add_table(shared_table);
  538. OFFLOAD_DEBUG_TRACE(2, "Registering MYO shared vtable table %p\n",
  539. shared_vtable);
  540. __offload_myo_vtable_tables.add_table(shared_vtable);
  541. OFFLOAD_DEBUG_TRACE(2, "Registering MYO function table %p\n", fptr_table);
  542. __offload_myo_func_tables.add_table(fptr_table);
  543. OFFLOAD_DEBUG_TRACE(2, "Registering MYO init table %p\n", init_table);
  544. __offload_myo_init_tables.add_table(init_table);
  545. }
  546. extern "C" void __offload_myoRemoveTables(
  547. MYOInitTableList::Node *init_table,
  548. MYOVarTableList::Node *shared_table,
  549. MYOVarTableList::Node *shared_vtable,
  550. MYOFuncTableList::Node *fptr_table
  551. )
  552. {
  553. OFFLOAD_DEBUG_TRACE(3, "%s\n", __func__);
  554. OFFLOAD_DEBUG_TRACE(2, "Removing MYO shared var table %p\n",
  555. shared_table);
  556. __offload_myo_var_tables.remove_table(shared_table);
  557. OFFLOAD_DEBUG_TRACE(2, "Removing MYO shared vtable table %p\n",
  558. shared_vtable);
  559. __offload_myo_vtable_tables.remove_table(shared_vtable);
  560. OFFLOAD_DEBUG_TRACE(2, "Removing MYO function table %p\n", fptr_table);
  561. __offload_myo_func_tables.remove_table(fptr_table);
  562. OFFLOAD_DEBUG_TRACE(2, "Removing MYO init table %p\n", init_table);
  563. __offload_myo_init_tables.remove_table(init_table);
  564. }
  565. #endif // MYO_SUPPORT