codes-workload.h 9.78 KB
Newer Older
1 2 3 4 5 6
/*
 * Copyright (C) 2013 University of Chicago.
 * See COPYRIGHT notice in top-level directory.
 *
 */

7
/* I/O workload generator API to be used for reading I/O operations into
Philip Carns's avatar
Philip Carns committed
8 9 10
 * storage system simulations.  This API just describes the operations to be
 * executed; it does not service the operations.
 */
11 12 13 14

#ifndef CODES_WORKLOAD_H
#define CODES_WORKLOAD_H

15 16 17
#include <ross.h>
#include "configuration.h"

18
#define MAX_NAME_LENGTH_WKLD 512
19

20
/* implementations included with codes */
Jonathan Jenkins's avatar
Jonathan Jenkins committed
21
typedef struct iomock_params iomock_params;
22
typedef struct iolang_params iolang_params;
23
typedef struct darshan_params darshan_params;
24
typedef struct recorder_params recorder_params;
25

26 27
/* struct to hold the actual data from a single MPI event*/
typedef struct dumpi_trace_params dumpi_trace_params;
28
typedef struct checkpoint_wrkld_params checkpoint_wrkld_params;
29

Jonathan Jenkins's avatar
Jonathan Jenkins committed
30 31 32 33 34 35 36 37 38 39 40 41
struct iomock_params
{
    uint64_t file_id;
    int use_uniq_file_ids;
    int is_write;
    int num_requests;
    int request_size;
    // for optimizing lookup - set higher (>= num ranks) to reduce collisions
    // and 0 to use the default
    int rank_table_size;
};

42
struct iolang_params
43
{
Jonathan Jenkins's avatar
Jonathan Jenkins committed
44
    /* the rank count is defined in the workload config file */
45
    int num_cns;
46 47
    /* flag - use path to find kernel files relative to the metafile */
    int use_relpath;
48
    char io_kernel_meta_path[MAX_NAME_LENGTH_WKLD];
49
    /* set by config in the metadata path */
50
    char io_kernel_path[MAX_NAME_LENGTH_WKLD];
51 52
};

53 54 55
struct darshan_params
{
    char log_file_path[MAX_NAME_LENGTH_WKLD];
56
    int64_t aggregator_cnt;
57 58
};

59 60 61
struct recorder_params
{
    char trace_dir_path[MAX_NAME_LENGTH_WKLD];
62
    int64_t nprocs;
63 64
};

65 66
struct dumpi_trace_params {
   char file_name[MAX_NAME_LENGTH_WKLD];
67
   int num_net_traces;
68 69
};

70 71 72 73 74 75 76 77
struct checkpoint_wrkld_params
{
    int nprocs; /* number of workload processes */
    double checkpoint_sz; /* size of checkpoint, in TiB */
    double checkpoint_wr_bw; /* checkpoint write b/w, in GiB/s */
    double app_runtime; /* app runtime, in hours */
    double mtti; /* mean time to interrupt, in hours */
};
78

79 80 81 82
/* supported I/O operations */
enum codes_workload_op_type
{
    /* terminator; there are no more operations for this rank */
83
    CODES_WK_END = 1,
84 85 86 87
    /* sleep/delay to simulate computation or other activity */
    CODES_WK_DELAY,
    /* block until specified ranks have reached the same point */
    CODES_WK_BARRIER,
88 89

    /* IO operations */
90 91
    /* open */
    CODES_WK_OPEN,
92
    /* close */
93 94 95 96
    CODES_WK_CLOSE,
    /* write */
    CODES_WK_WRITE,
    /* read */
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
    CODES_WK_READ,

    /* network operations (modelled after MPI operations) */
    /* blocking send operation */
    CODES_WK_SEND,
    /* blocking recv operation */
    CODES_WK_RECV,
    /* non-blocking send operation */
    CODES_WK_ISEND,
    /* non-blocking receive operation */
    CODES_WK_IRECV,
    /* broadcast operation */
    CODES_WK_BCAST,
    /* Allgather operation */
    CODES_WK_ALLGATHER,
    /* Allgatherv operation */
    CODES_WK_ALLGATHERV,
    /* Alltoall operation */
    CODES_WK_ALLTOALL,
    /* Alltoallv operation */
    CODES_WK_ALLTOALLV,
    /* Reduce operation */
    CODES_WK_REDUCE,
    /* Allreduce operation */
    CODES_WK_ALLREDUCE,
    /* Generic collective operation */
    CODES_WK_COL,
124
    /* Waitall operation */
125
    CODES_WK_WAITALL,
126
    /* Wait operation */
127
    CODES_WK_WAIT,
128
    /* Waitsome operation */
129
    CODES_WK_WAITSOME,
130
    /* Waitany operation */
131
    CODES_WK_WAITANY,
132
    /* Testall operation */
133
    CODES_WK_TESTALL,
Jonathan Jenkins's avatar
Jonathan Jenkins committed
134 135 136 137

    /* for workloads that have events not yet handled
     * (eg the workload language) */
    CODES_WK_IGNORE
138 139 140 141 142 143 144 145 146
};

/* I/O operation paramaters */
struct codes_workload_op
{
    /* TODO: do we need different "classes" of operations to differentiate
     * between different APIs?
     */

Philip Carns's avatar
Philip Carns committed
147
    /* what type of operation this is */
148
    enum codes_workload_op_type op_type;
149 150 151
    /* currently only used by network workloads */
    double start_time;
    double end_time;
152
    double sim_start_time;
153

Philip Carns's avatar
Philip Carns committed
154
    /* parameters for each operation type */
155 156 157 158
    union
    {
        struct {
            double seconds;
159
	    double nsecs;
160 161
        } delay;
        struct {
Philip Carns's avatar
Philip Carns committed
162
            int count;  /* num ranks in barrier, -1 means "all" */
163 164 165
            int root;   /* root rank */
        } barrier;
        struct {
166
            uint64_t file_id;      /* integer identifier for the file */
167 168 169
            int create_flag;  /* file must be created, not just opened */
        } open;
        struct {
170
            uint64_t file_id;  /* file to operate on */
171 172 173 174
            off_t offset; /* offset and size */
            size_t size;
        } write;
        struct {
175
            uint64_t file_id;  /* file to operate on */
176 177 178 179
            off_t offset; /* offset and size */
            size_t size;
        } read;
        struct {
180
            uint64_t file_id;  /* file to operate on */
181
        } close;
182 183 184 185 186 187 188 189
        struct {
            /* TODO: not sure why source rank is here */
            int source_rank;/* source rank of MPI send message */
            int dest_rank; /* dest rank of MPI send message */
            int num_bytes; /* number of bytes to be transferred over the network */
            int data_type; /* MPI data type to be matched with the recv */
            int count; /* number of elements to be received */
            int tag; /* tag of the message */
190
            int16_t req_id;
191 192 193 194 195 196 197 198 199
        } send;
        struct {
            /* TODO: not sure why source rank is here */
            int source_rank;/* source rank of MPI recv message */
            int dest_rank;/* dest rank of MPI recv message */
            int num_bytes; /* number of bytes to be transferred over the network */
            int data_type; /* MPI data type to be matched with the send */
            int count; /* number of elements to be sent */
            int tag; /* tag of the message */
200
            int16_t req_id;
201 202 203 204 205
        } recv;
        /* TODO: non-stub for other collectives */
        struct {
            int num_bytes;
        } collective;
206 207 208 209 210 211 212
        struct {
            int count;
            int16_t* req_ids;
        } waits;
        struct {
            int16_t req_id;
        } wait;
213
    }u;
214 215
};

216 217 218 219 220 221 222
// helper macro for implementations - call this if multi-app support not
// available
#define APP_ID_UNSUPPORTED(id, name) \
    if (id != 0) \
        tw_error(TW_LOC,\
                "APP IDs not supported for %s generator, 0 required", name);

223 224 225 226 227 228 229 230 231
/* read workload configuration from a CODES configuration file and return the
 * workload name and parameters, which can then be passed to
 * codes_workload_load */
typedef struct
{
    char const * type;
    void * params;
} codes_workload_config_return;

232 233 234
// NOTE: some workloads (iolang, checkpoint) require information about the
// total number of ranks to correctly process traces/config files, etc. Other
// workload generators (darshan) ignore it
235 236
codes_workload_config_return codes_workload_read_config(
        ConfigHandle * handle,
237 238 239
        char const * section_name,
        char const * annotation,
        int num_ranks);
240 241 242

void codes_workload_free_config_return(codes_workload_config_return *c);

243 244
/* load and initialize workload of of type "type" with parameters specified by
 * "params".  The rank is the caller's relative rank within the collection
245 246 247
 * of processes that will participate in this workload. The app_id is the
 * "application" that the rank is participating in, used to differentiate
 * between multiple, concurrent workloads
248 249 250 251
 *
 * This function is intended to be called by a compute node LP in a model
 * and may be called multiple times over the course of a
 * simulation in order to execute different application workloads.
252
 *
253 254 255
 * Returns and identifier that can be used to retrieve operations later.
 * Returns -1 on failure.
 */
256 257 258 259 260
int codes_workload_load(
        const char* type,
        const char* params,
        int app_id,
        int rank);
261 262 263 264 265

/* Retrieves the next I/O operation to execute.  the wkld_id is the
 * identifier returned by the init() function.  The op argument is a pointer
 * to a structure to be filled in with I/O operation information.
 */
266 267 268 269 270
void codes_workload_get_next(
        int wkld_id,
        int app_id,
        int rank,
        struct codes_workload_op *op);
271 272

/* Reverse of the above function. */
273 274 275 276 277
void codes_workload_get_next_rc(
        int wkld_id,
        int app_id,
        int rank,
        const struct codes_workload_op *op);
278

279
/* Retrieve the number of ranks contained in a workload */
280 281 282 283
int codes_workload_get_rank_cnt(
        const char* type,
        const char* params,
        int app_id);
284

285
/* for debugging/logging: print an individual operation to the specified file */
286 287 288 289 290
void codes_workload_print_op(
        FILE *f,
        struct codes_workload_op *op,
        int app_id,
        int rank);
291

292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307
/* implementation structure */
struct codes_workload_method
{
    char *method_name; /* name of the generator */
    void * (*codes_workload_read_config) (
            ConfigHandle *handle, char const * section_name,
            char const * annotation, int num_ranks);
    int (*codes_workload_load)(const char* params, int app_id, int rank);
    void (*codes_workload_get_next)(int app_id, int rank, struct codes_workload_op *op);
    int (*codes_workload_get_rank_cnt)(const char* params, int app_id);
};

/* dynamically add to the workload implementation table. Must be done BEFORE
 * calls to codes_workload_read_config or codes_workload_load */
void codes_workload_add_method(struct codes_workload_method const * method);

308 309 310 311 312 313 314 315 316 317 318 319
/* NOTE: there is deliberately no finalize function; we don't have any
 * reliable way to tell when a workload is truly done and will not
 * participate in further reverse computation.   The underlying generators
 * will shut down automatically once they have issued their last event.
 */

#endif /* CODES_WORKLOAD_H */

/*
 * Local variables:
 *  c-indent-level: 4
 *  c-basic-offset: 4
320
 *  indent-tabs-mode: nil
321 322 323 324
 * End:
 *
 * vim: ft=c ts=8 sts=4 sw=4 expandtab
 */