Skip to content

tw_lp_setup_types

Elsa Gonsiorowski edited this page Jan 22, 2015 · 1 revision

Added Variables and Functions

Global Type Array

The global type array is store in g_tw_lp_types. This is an array of LP types, as defined in ross-types.h:

struct tw_lptype {
    init_f init;
    pre_run_f pre_run;
    event_f event;
    revent_f revent;
    final_f final;
    map_f map;
    size_t state_sz;
};

Global Type Mapping Function

If you multiple LP types you will have to implement a mapping function. This function takes an LP's global ID (gid) and returns an index within the type array. This function has the prototype: tw_lpid tw_typemap_f (tw_lpid gid) and should be assigned to the g_tw_lp_typemap variable.

Note that the g_tw_lp_typemap has a default function assigned. This function assumes that there is only one LP type and therefore always returns 0.

Model Use Case

This code shows how the phold model might take advantage of the new LP type functionality.

    // this call must come first
    tw_define_lps(nlp_per_pe, sizeof(phold_message), 0);

    // existing type array called mylps
    g_tw_lp_types = mylps;
    tw_lp_setup_types();