mirror of
https://github.com/augustin64/projet-tipe
synced 2025-01-24 07:36:24 +01:00
Add cuda_utils
This commit is contained in:
parent
7c0b70ce25
commit
f27d7542f8
29
src/mnist/cuda_utils.cu
Normal file
29
src/mnist/cuda_utils.cu
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
|
int*** copy_images_cuda(int*** images, int nb_images, int width, int height) {
|
||||||
|
int*** images_cuda;
|
||||||
|
cudaMalloc((int****)&images_cuda, sizeof(int**)*nb_images);
|
||||||
|
cudaMemcpy((int****)&images_cuda, sizeof(int**)*nb_images, images);
|
||||||
|
|
||||||
|
for (int i=0; i < nb_images; i++) {
|
||||||
|
cudaMalloc((int***)&images_cuda[i], sizeof(int**)*nb_images);
|
||||||
|
cudaMemcpy((int***)&images_cuda[i], sizeof(int**)*nb_images, images[i]);
|
||||||
|
for (int j=0; j < height; j++) {
|
||||||
|
cudaMalloc((int**)&images_cuda[i][j], sizeof(int*)*width);
|
||||||
|
cudaMemcpy((int**)&images_cuda[i][j], sizeof(int*)*width, images[i][j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return images_cuda;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
unsigned int* copy_labels_cuda(unsigned int* labels) {
|
||||||
|
unsigned int* labels_cuda;
|
||||||
|
cudaMalloc((unsigned int**)&labels_cuda, sizeof(labels));
|
||||||
|
cudaMemcpy((unsigned int**)&labels_cuda, sizeof(labels), labels);
|
||||||
|
return labels_cuda;
|
||||||
|
}
|
10
src/mnist/include/cuda_utils.h
Normal file
10
src/mnist/include/cuda_utils.h
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#ifndef DEF_CUDA_UTILS_H
|
||||||
|
#define DEF_CUDA_UTILS_H
|
||||||
|
|
||||||
|
int*** copy_images_cuda(int*** images, int nb_images, int width, int height);
|
||||||
|
unsigned int* copy_labels_cuda(unsigned int* labels);
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user