Files
amsculib3/old/9apr26_prerefactor/include/amsculib2/amscurarray.cuh
2026-04-10 13:29:50 -04:00

66 lines
2.2 KiB
Plaintext

#ifndef __AMSCURARRAY_HPP__
#define __AMSCURARRAY_HPP__
namespace amscuda
{
//Cuda ragged array class
template<typename T> class curarray
{
public:
int device;
curarray* devptr; //pointer to mirror class on the device
int Narrays; //number of arrays
int *N; //dimension of each array
T** hostarrayptrs; //pointers to each array on the host - null on the device
T** devarrayptrs; //pointers to each array on the device
//the double pointer is a host pointer to device pointers on the host class
//for the device class, only the second set of arrays is in use
//the constructor and destructor set all pointers to NULL, they
// do *not* manage memory. This is done with curarray_new and curarray_delete
__device__ __host__ curarray();
__device__ __host__ ~curarray();
__host__ int push();
__host__ int pull();
//__device__ int dev_resizearray(int arraynum, int arraysize);
__host__ int resizearray(int arraynum, int arraysize);
// I may want a way to resize arrays on the device without pushing/pulling all the array contents
};
template<typename T> int curarray_new(curarray<T>** ptr, int Narrays);
template<typename T> int curarray_delete(curarray<T>** ptr);
template<typename T> int curarray_device_new(curarray<T> *hostptr);
template<typename T> int curarray_device_delete(curarray<T> *hostptr);
template<typename T> int curarray_push(curarray<T> *hostptr);
template<typename T> int curarray_pull(curarray<T> *hostptr);
//template<typename T> int curarray_host_fillall(curarray<T> *hostptr, const T &val);
//template<typename T> int curarray_device_fillall(curarray<T> *hostptr, const T &val);
//template<typename T> __host__ int curarray_deletearray(curarray<T> *hostptr, int arrayindex);
//template<typename T> __device__ int curarray_dev_deletearray(curarray<T> *devptr, int arrayindex);
//template<typename T> __host__ int curarray_allocarray(curarray<T> *hostptr, int arrayindex, int size);
//template<typename T> __device__ int curarray_dev_allocarray(curarray<T> *devptr, int arrayindex, int size);
void test_amscurarray1();
};
#include <amsculib2/amscurarray_impl.cuh>
#endif