2023-01-28 22:04:38 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdbool.h>
|
2023-01-29 09:40:55 +01:00
|
|
|
|
2023-01-28 22:04:38 +01:00
|
|
|
#ifdef USE_CUDA
|
2023-01-29 09:40:55 +01:00
|
|
|
#ifndef __CUDACC__
|
|
|
|
#include "cuda_runtime.h"
|
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
#ifdef __CUDACC__
|
|
|
|
#define USE_CUDA
|
|
|
|
#endif
|
2023-01-28 22:04:38 +01:00
|
|
|
#endif
|
|
|
|
|
2022-11-11 11:20:30 +01:00
|
|
|
#ifndef DEF_UTILS_CU_H
|
|
|
|
#define DEF_UTILS_CU_H
|
|
|
|
|
|
|
|
#ifdef __CUDACC__
|
|
|
|
/* CUDA memcheck */
|
|
|
|
#define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); }
|
|
|
|
inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort=true) {
|
|
|
|
if (code != cudaSuccess) {
|
|
|
|
fprintf(stderr,"GPUassert: %s %s %d\n", cudaGetErrorString(code), file, line);
|
|
|
|
if (abort) exit(code);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Partie entière supérieure de a/b
|
|
|
|
*/
|
|
|
|
int i_div_up(int a, int b);
|
|
|
|
|
2023-01-29 09:40:55 +01:00
|
|
|
#ifdef __CUDACC__
|
2023-02-15 11:22:51 +01:00
|
|
|
extern "C"
|
2023-01-29 09:40:55 +01:00
|
|
|
#endif
|
2023-02-19 15:08:02 +01:00
|
|
|
/*
|
|
|
|
* Vérification de la compatibilité CUDA
|
|
|
|
*/
|
2022-11-11 11:20:30 +01:00
|
|
|
bool check_cuda_compatibility();
|
|
|
|
|
2023-03-28 12:38:06 +02:00
|
|
|
#ifdef __CUDACC__
|
|
|
|
extern "C"
|
|
|
|
#endif
|
|
|
|
/*
|
|
|
|
* Copier des valeurs d'un tableau de dimension 3 de mémoire partagée
|
|
|
|
*/
|
|
|
|
void copy_3d_array(float*** source, float*** dest, int dimension1, int dimension2, int dimension3);
|
2022-11-11 11:20:30 +01:00
|
|
|
#endif
|