README.codes-mapping.txt 3.29 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
- The codes-mapping.h header file contains the function definitions for the codes LP mapping.

Step 1: Specifying the LP types in the config file:

- Here is an example of a config file that specifies the codes LP mapping
-------------------------------example-test.conf-----------------------------
LPGROUPS
{
   MODELNET_GRP
   {
      repetitions="16";
      server="1";
      example_net="1";
   }
}
------------------------------------------------------------------------------
In this config file, there are multiple LP types defined in a single LP group (As we will see in a later
example, there can be multiple LP groups in a config file too). There is 1 server LP and 1 example_net
LP type in a group and this combination is repeated 16 time (repetitions="16"). ROSS will assign the 
LPs to the PEs (PEs is an abstraction for MPI rank in ROSS) by placing 1 server LP then 1 example_net
LP a total of 16 times. This configuration is useful if there is some form of communication involved
between the server and example_net LP types, in which case ROSS will place them on the same PE and 
communication between server and example_net LPs will not involve remote messages. 
The number of server and example_net LPs can be more than 1. Lets assume if we have two example_net
LPs for each server then the config file will have the following format:

-------------------------------example-test2.conf-----------------------------
LPGROUPS
{
   MODELNET_GRP
   {
      repetitions="16";
      server="1";
      example_net="2";
   }
}
------------------------------------------------------------------------------

Step 2: Loading the config file in the model:

After the initialization function calls of ROSS (tw_init), the configuration file can be loaded in the
example program using:

configuration_load(example-test.conf, MPI_COMM_WORLD, &config);

Step 3: Each LP type must register itself  with the lp_type_register before setting up the codes-mapping. 
Following is an example function that registers 'server' lp type.

static void svr_add_lp_type()
{
  lp_type_register("server", svr_get_lp_type());
}

Step 4: Call to codes_mapping_setup that sets up the LPs of each registered LP type as specified in the config
file.

codes_mapping_setup();

Step 5: Querying number of LPs in a repetition

int codes_mapping_get_lp_count(group_name, lp_type_name);

For example, to query the number of server LPs in example-test2.conf file, calling

num_servers = codes_mapping_get_lp_count("MODELNET_GRP", "server");
 
will return 2.

Step 6: Querying number of repetitions in a particular group, use

int codes_mapping_get_group_reps(group_name);

For example, to query the number of repetitions in example-test2.conf file, calling

num_repetitions = codes_mapping_get_group_reps("MODELNET_GRP");

will return 16.
78 79 80 81 82 83 84 85 86 87

=== LP to PE mapping for parallel simulations ===

In the case of parallel simulations using MPI, the LP mapping explained in Step
1 still holds. However, these LPs must also be mapped to PEs, which can be an
arbitrary mapping in ROSS. We simply assign the first N LPs to the first PE, the
second N to the second PE, and so forth, where N is the floor of the LP count
and the PE count. If the number of LPs is not divisible by the number of PEs,
then the first N+1 LPs are mapped to the first PE and so on, until the remainder
has been taken care of.