Assignments for parallel processing using OpenMPI.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

32 lines
1.1 KiB

#ifndef COMMON_H
#define COMMON_H
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>
#include <mpi.h>
// Avoids aggresive memory reallocation at the beginning of buffer growth sequence
#define INIT_BUFFER_SIZE 16
// Optimal exponential buffer growth factor, 2 is sometimes used to
#define GROWTH_FACTOR 1.5
// Maximum length of the file that will be read (not applicable to a1)
#define MAX_LINE_LENGTH 8192
// TODO: define custom structure for this probably
#define CODE_SIZE 0
#define CODE_INDEX 1
#define NUM_CODES 2
void *my_malloc(size_t size);
void *my_calloc(size_t nitems, size_t size);
void *my_realloc(void *ptr, size_t size);
FILE *my_fopen(const char *filename, const char *mode);
void *buffer_grow(void *ptr, int sizeBufferUsed, int *sizeBufferTotal);
bool check_parallel_worth(int numProcesses, int numCount, int limit);
void spread_evenly(int numProcesses, int sizeBufferUsed, int multiplier, int **arrBlockIndices, int **arrBlockSizes);
void *read_matrix_file(const char *filename, int *numCols, int *numCount);
int transpose_index(int index, int rows, int cols);
#endif