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

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

#ifndef CODES_WORKLOAD_H
#define CODES_WORKLOAD_H

#include "ross.h"

17 18 19 20 21 22 23 24 25 26 27
typedef struct bgp_params bgp_params;

struct bgp_params
{
    int num_cns_per_lp;
    char* io_kernel_meta_path;
    char* bgp_config_file;
    char* io_kernel_path;
    char* io_kernel_def_path;
};

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
/* supported I/O operations */
enum codes_workload_op_type
{
    /* terminator; there are no more operations for this rank */
    CODES_WK_END = 1, 
    /* sleep/delay to simulate computation or other activity */
    CODES_WK_DELAY,
    /* block until specified ranks have reached the same point */
    CODES_WK_BARRIER,
    /* open */
    CODES_WK_OPEN,
    /* close */ 
    CODES_WK_CLOSE,
    /* write */
    CODES_WK_WRITE,
    /* read */
    CODES_WK_READ
};

/* 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
54
    /* what type of operation this is */
55 56
    enum codes_workload_op_type op_type;

Philip Carns's avatar
Philip Carns committed
57
    /* parameters for each operation type */
58 59 60 61 62 63
    union
    {
        struct {
            double seconds;
        } delay;
        struct {
Philip Carns's avatar
Philip Carns committed
64
            int count;  /* num ranks in barrier, -1 means "all" */
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
            int root;   /* root rank */
        } barrier;
        struct {
            int file_id;      /* integer identifier for the file */
            int create_flag;  /* file must be created, not just opened */
        } open;
        struct {
            int file_id;  /* file to operate on */
            off_t offset; /* offset and size */
            size_t size;
        } write;
        struct {
            int file_id;  /* file to operate on */
            off_t offset; /* offset and size */
            size_t size;
        } read;
        struct {
            int file_id;  /* file to operate on */
        } close;
84
    }u;
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
};

/* load and initialize workload of of type "type" with parameters specified by
 * "params".  The rank is the caller's relative rank within the collection
 * of processes that will participate in this workload.   
 *
 * 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.
 * 
 * Returns and identifier that can be used to retrieve operations later.
 * Returns -1 on failure.
 */
int codes_workload_load(const char* type, const char* params, int rank);

/* 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.
 */
104
void codes_workload_get_next(int wkld_id, int rank, struct codes_workload_op *op);
105 106

/* Reverse of the above function. */
107
void codes_workload_get_next_rc(int wkld_id, int rank, const struct codes_workload_op *op);
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124

/* 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
 * End:
 *
 * vim: ft=c ts=8 sts=4 sw=4 expandtab
 */