JacobiHPC/src/utils.cuh

56 lines
1.2 KiB
Plaintext

#include <stdio.h>
#include <stdlib.h>
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
/* #define ENABLE_LOG */
#ifdef ENABLE_LOG
# define LOG(x) x
#else
# define LOG(x) (void) 0
#endif
/*
* Macro used with single array matrices to
* get the array index given the number of columns,
* the row index and the column index.
*/
#define IDX(cols, r, c) ((r) * (cols) + (c))
typedef struct borders {
float north;
float east;
float south;
float west;
} borders;
/*
* Create a matrix stored in a single array.
*/
__host__ float *create_sa_matrix(int rows, int cols);
__host__ float *create_sa_matrix_on_gpu(int rows, int cols, cudaError_t *cuda_status);
/*
* Destroy a single array matrix.
*/
__host__ void destroy_sa_matrix(float *x);
__host__ void destroy_sa_matrix_on_gpu(float *x);
__host__ void initialize_matrix_on_gpu(float *x, int rows, int cols, cudaError_t *cuda_status);
__host__ float *retrieve_sa_matrix_from_gpu(float *x, int rows, int cols, cudaError_t *cuda_status);
/*
* Print a single array matrix.
*/
__host__ void print_sa_matrix(float *x, int rows, int cols);
__host__ float **create_matrix(int rows, int cols);
__host__ void destroy_matrix(float **x, int rows);
__host__ void print_matrix(float **x, int rows, int cols);