codes-jobmap.h 2.51 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
/*
 * Copyright (C) 2015 University of Chicago.
 * See COPYRIGHT notice in top-level directory.
 *
 */

/* SUMMARY - namespace support for multiple groups of ids (jobs) with respect to a
 * flat namespace. Note that this API is meant for static job creation - a more
 * sophisticated method would need to be used to modify job mappings at
 * runtime.
 *
 * Example:
 *
14
 * job  0      1    2        (<-- jobmap defined "job" IDs)
15 16
 * rank 0 1 2  0 1  0 1 2 3  (<-- "job local" IDs)
 * ID   0 1 2  3 4  5 6 7 8  (<-- jobmap-defined LP relative "global" IDs)
17 18 19 20 21 22
 * LP   A B C  D E  F G H I  (<-- provided by codes-mapping)
 * */

#ifndef CODES_JOBMAP_H
#define CODES_JOBMAP_H

Jonathan Jenkins's avatar
Jonathan Jenkins committed
23 24 25 26
#ifdef __cplusplus
extern "C" {
#endif

27 28 29
/** type markers and parameter defs for jobmaps **/

enum codes_jobmap_type {
30 31 32 33 34 35 36 37 38 39
    /* the "identity" jobmap is a shim for single-job workloads */
    CODES_JOBMAP_IDENTITY,
    /* the "list" jobmap allows the explicit specification of mappings from
     * jobs to lists of global ids through a text file, wiht one line per job
     */
    CODES_JOBMAP_LIST,
    /* the "dummy" jobmap is an example implementation for testing, and can be
     * seen as the inverse of the identity mapping.
     * It simply specifies N jobs, with exactly one rank per job, with a trivial
     * mapping */
40
    CODES_JOBMAP_DUMMY,
41 42 43 44
};

struct codes_jobmap_params_identity {
    int num_ranks;
45 46 47 48 49 50
};

struct codes_jobmap_params_dummy {
    int num_jobs;
};

51
struct codes_jobmap_params_list {
52
    char *alloc_file;
53
};
54 55


56 57
/** jobmap interface **/

58
struct codes_jobmap_ctx;
59 60 61 62 63 64 65 66 67 68
struct codes_jobmap_id {
    int job;
    int rank; // relative to job
};

struct codes_jobmap_ctx *
codes_jobmap_configure(enum codes_jobmap_type t, void const * params);

void codes_jobmap_destroy(struct codes_jobmap_ctx *c);

69 70 71 72 73 74 75
/* main mapping functions - bidirectional mapping is needed:
 * - global -> local ID for initialization
 * - local -> global ID for communication between local IDs
 *
 * functions return {-1, -1} and -1, respectively, for invalid id input */

struct codes_jobmap_id codes_jobmap_to_local_id(
76 77 78
        int id,
        struct codes_jobmap_ctx const * c);

79 80 81 82
int codes_jobmap_to_global_id(
        struct codes_jobmap_id id,
        struct codes_jobmap_ctx const * c);

83 84
int codes_jobmap_get_num_jobs(struct codes_jobmap_ctx const * c);

85 86
int codes_jobmap_get_num_ranks(int job_id, struct codes_jobmap_ctx const * c);

Jonathan Jenkins's avatar
Jonathan Jenkins committed
87 88 89 90
#ifdef __cplusplus
}
#endif

91 92 93 94 95 96 97 98 99 100 101
#endif

/*
 * Local variables:
 *  c-indent-level: 4
 *  c-basic-offset: 4
 *  indent-tabs-mode: nil
 * End:
 *
 * vim: ts=8 sts=4 sw=4 expandtab
 */