core_manager.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #ifndef CORE_MANAGER_H
  2. #define CORE_MANAGER_H
  3. #include "fixed_types.h"
  4. #include "tls.h"
  5. #include "lock.h"
  6. #include "log.h"
  7. #include "core.h"
  8. #include <iostream>
  9. #include <fstream>
  10. #include <map>
  11. #include <vector>
  12. class Core;
  13. class CoreManager
  14. {
  15. public:
  16. CoreManager();
  17. ~CoreManager();
  18. enum ThreadType {
  19. INVALID,
  20. APP_THREAD, // Application (Pin) thread
  21. CORE_THREAD, // Core (Performance model) thread
  22. SIM_THREAD // Simulator (Network model) thread
  23. };
  24. void initializeCommId(SInt32 comm_id);
  25. void initializeThread(core_id_t core_id);
  26. void terminateThread();
  27. core_id_t registerSimThread(ThreadType type);
  28. core_id_t getCurrentCoreID(int threadIndex = -1) // id of currently active core (or INVALID_CORE_ID)
  29. {
  30. Core *core = getCurrentCore(threadIndex);
  31. if (!core)
  32. return INVALID_CORE_ID;
  33. else
  34. return core->getId();
  35. }
  36. Core *getCurrentCore(int threadIndex = -1)
  37. {
  38. return m_core_tls->getPtr<Core>(threadIndex);
  39. }
  40. Core *getCoreFromID(core_id_t core_id);
  41. bool amiUserThread();
  42. bool amiCoreThread();
  43. bool amiSimThread();
  44. private:
  45. UInt32 *tid_map;
  46. TLS *m_core_tls;
  47. TLS *m_thread_type_tls;
  48. UInt32 m_num_registered_sim_threads;
  49. UInt32 m_num_registered_core_threads;
  50. Lock m_num_registered_threads_lock;
  51. std::vector<Core*> m_cores;
  52. };
  53. #endif