Charades
mapper.h
1 #ifndef MAPPER_H_
2 #define MAPPER_H_
3 
7 class LPMapper {
8  public:
10  virtual uint64_t get_chare_id(uint64_t global_id) const = 0;
12  virtual uint64_t get_local_id(uint64_t global_id) const = 0;
16  virtual uint64_t get_global_id(uint64_t chare_id, uint64_t local_id) const = 0;
18  virtual uint64_t get_num_lps(uint64_t chare_id) const = 0;
19 };
20 
25 class BlockMapper : public LPMapper {
27  uint64_t get_chare_id(uint64_t global_id) const {;
28  return global_id / g_lps_per_chare;
29  }
31  uint64_t get_local_id(uint64_t global_id) const {
32  return global_id % g_lps_per_chare;
33  }
38  uint64_t get_global_id(uint64_t chare_id, uint64_t local_id) const {
39  return g_lps_per_chare * chare_id + local_id;
40  }
42  uint64_t get_num_lps(uint64_t chare_id) const {
43  return g_lps_per_chare;
44  }
45 };
46 
47 #endif
virtual uint64_t get_chare_id(uint64_t global_id) const =0
Maps a global LP id, gid, to a chare id.
virtual uint64_t get_local_id(uint64_t global_id) const =0
Maps a global LP id, gid, to its local offset id within its chare.
unsigned g_lps_per_chare
number of LPs per chare (if constant)
Definition: globals.C:16
uint64_t get_global_id(uint64_t chare_id, uint64_t local_id) const
The global id for (chare_id,\ p local_id) is g_lps_per_chare * chare_id + local_id.
Definition: mapper.h:38
uint64_t get_chare_id(uint64_t global_id) const
The chare id where gid is located is gid / g_lps_per_chare.
Definition: mapper.h:27
uint64_t get_num_lps(uint64_t chare_id) const
The number of lps on all chares is g_lps_per_chare.
Definition: mapper.h:42
Concrete implementation of a basic block mapping to be used as a default.
Definition: mapper.h:25
Base class which defines the mapper interface used during simulation setup.
Definition: mapper.h:7
uint64_t get_local_id(uint64_t global_id) const
The local offset of gid is gid % g_lps_per_chare.
Definition: mapper.h:31
virtual uint64_t get_global_id(uint64_t chare_id, uint64_t local_id) const =0
Maps a chare id and offset within the chare to a global LP id.
virtual uint64_t get_num_lps(uint64_t chare_id) const =0
Maps a chare id to the number of LPs that chare will have.