1 /* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #include "smpi_f2c.hpp"
8 #include "src/smpi/include/smpi_actor.hpp"
14 int mpi_status_ignore_;
15 int mpi_statuses_ignore_;
20 std::unordered_map<std::string, F2C*>* F2C::f2c_lookup_ = nullptr;
23 std::unordered_map<std::string, F2C*>* F2C::f2c_lookup()
28 void F2C::set_f2c_lookup(std::unordered_map<std::string, F2C*>* map)
33 void F2C::f2c_id_increment(){
41 char* F2C::get_key(char* key, int id) {
42 std::snprintf(key, KEY_SIZE, "%u", static_cast<unsigned>(id));
46 char* F2C::get_key_id(char* key, int id) {
47 std::snprintf(key, KEY_SIZE, "%u_%ld", static_cast<unsigned>(id), simgrid::s4u::this_actor::get_pid());
51 void F2C::delete_lookup(){
55 std::unordered_map<std::string, F2C*>* F2C::lookup()
60 void F2C::free_f(int id)
63 f2c_lookup_->erase(get_key(key, id));
68 if (f2c_lookup_ == nullptr)
69 f2c_lookup_ = new std::unordered_map<std::string, F2C*>;
72 (*f2c_lookup_)[get_key(key, f2c_id_)] = this;
79 if (f2c_lookup_ == nullptr) {
80 f2c_lookup_ = new std::unordered_map<std::string, F2C*>;
83 for (auto const& elm : *f2c_lookup_)
84 if (elm.second == this)
85 return std::stoi(elm.first);
87 /* this function wasn't found, add it */
93 if (f2c_lookup_ == nullptr)
94 f2c_lookup_ = new std::unordered_map<std::string, F2C*>;
98 auto comm = f2c_lookup_->find(get_key(key, id));
99 return comm == f2c_lookup_->end() ? nullptr : comm->second;