Download h source code

/*
 * Copyright 2021 Jeisson Hidalgo-Cespedes - Universidad de Costa Rica
 */

#ifndef STATIC_SIMULATION_H
#define STATIC_SIMULATION_H

#include <time.h>

#include "simulation.h"

/**
 * @remarks Update @a static_mapping_text and the private function run() if you
 * add a constant to this enumeration
 */
typedef enum {
  MAPPING_BLOCK,
  MAPPING_CYCLIC,
} static_mapping_t;

static const char* const static_mapping_text[] = {
  "Block",
  "Cyclic"
};

typedef struct {
  static_mapping_t mapping_type;
  simulation_t* simulation;
  data_t* durations;  // conditional safe
  struct timespec start_time;
} static_simulation_t;

int static_simulation_init(static_simulation_t* static_simulation
  , static_mapping_t mapping_type, simulation_t* simulation);
void static_simulation_destroy(static_simulation_t* static_simulation);
int static_simulation_run(static_simulation_t* static_simulation);

size_t calculate_block_start(size_t rank, size_t work_count
  , size_t worker_count);
size_t calculate_block_finish(size_t rank, size_t work_count
  , size_t worker_count);

#endif  // STATIC_SIMULATION_H