MCPcopy Create free account
hub / github.com/AdaptiveCpp/AdaptiveCpp / unregister_hcf_object

Method unregister_hcf_object

src/runtime/kernel_cache.cpp:374–406  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

372}
373
374void hcf_cache::unregister_hcf_object(hcf_object_id id) {
375 std::lock_guard<std::mutex> lock{_mutex};
376
377 auto it = _hcf_objects.find(id);
378 if(it != _hcf_objects.end()) {
379 // First remove the HCF object as a symbol provider for runtime linking and
380 // symbol resolution. This ensures that it gets no longer selected
381 // for symbol resolution.
382
383 // 1. Go through each symbol list (all device images) exported by this
384 // HCF file
385 for_each_exported_symbol_list(
386 *(it->second), [&](const common::hcf_container::node* image_node,
387 const std::vector<std::string> &exported_symbols) {
388 // 2. Iterate over all symbols exported in this HCF
389 for (const auto &symbol : exported_symbols) {
390 // 3. Remove all references to this HCF in the symbol providers map
391 auto& symbol_providers = _exported_symbol_providers[symbol];
392 symbol_providers.erase(
393 std::remove_if(symbol_providers.begin(), symbol_providers.end(),
394 [&](const device_image_id &img) {
395 return img.hcf_id == id;
396 }),
397 symbol_providers.end());
398 }
399 });
400 // Then we can remove the HCF itself.
401 // Note: We don't necessarily need to remove the HCF kernel info, since
402 // just maintaining this data won't have any side effects as long as
403 // the HCF object is no longer selected for execution.
404 _hcf_objects.erase(id);
405 }
406}
407
408const common::hcf_container* hcf_cache::get_hcf(hcf_object_id obj) const {
409 std::lock_guard<std::mutex> lock{_mutex};

Callers 1

__acpp_unregister_hcfFunction · 0.80

Calls 6

remove_ifFunction · 0.50
findMethod · 0.45
endMethod · 0.45
eraseMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected