2024-12-24 07:27:09 +00:00
|
|
|
|
#ifndef _GPUTOOL_H_
|
|
|
|
|
#define _GPUTOOL_H_
|
2025-02-06 13:18:25 +00:00
|
|
|
|
#include "GPUBaseLibAPI.h"
|
2024-12-24 07:27:09 +00:00
|
|
|
|
#include "BaseConstVariable.h"
|
2025-01-15 03:57:07 +00:00
|
|
|
|
|
|
|
|
|
#ifdef __CUDANVCC___
|
2024-12-24 07:27:09 +00:00
|
|
|
|
#include <cuda_runtime.h>
|
|
|
|
|
#include <device_launch_parameters.h>
|
|
|
|
|
#include <cublas_v2.h>
|
|
|
|
|
#include <cuComplex.h>
|
|
|
|
|
|
|
|
|
|
#define __CUDADEBUG__
|
|
|
|
|
|
|
|
|
|
#define CUDAMEMORY Memory1MB*100
|
|
|
|
|
|
|
|
|
|
#define LAMP_CUDA_PI 3.141592653589793238462643383279
|
|
|
|
|
|
2025-01-27 03:37:46 +00:00
|
|
|
|
// SHAREMEMORY_FLOAT_HALF_STEP * BLOCK_SIZE = SHAREMEMORY_FLOAT_HALF
|
2025-01-02 10:53:33 +00:00
|
|
|
|
#define BLOCK_SIZE 256
|
2025-01-20 07:49:54 +00:00
|
|
|
|
#define SHAREMEMORY_BYTE 49152
|
|
|
|
|
#define SHAREMEMORY_FLOAT_HALF 6144
|
2025-01-27 03:37:46 +00:00
|
|
|
|
#define SHAREMEMORY_FLOAT_HALF_STEP 24
|
2025-01-15 10:48:43 +00:00
|
|
|
|
|
2025-02-06 13:18:25 +00:00
|
|
|
|
|
2024-12-24 07:27:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum LAMPGPUDATETYPE {
|
2025-02-07 11:47:41 +00:00
|
|
|
|
LAMP_LONG,
|
|
|
|
|
LAMP_FLOAT,
|
|
|
|
|
LAMP_COMPLEXFLOAT
|
2024-12-24 07:27:09 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
extern "C" struct CUDAVector {
|
2025-02-07 11:47:41 +00:00
|
|
|
|
float x;
|
|
|
|
|
float y;
|
|
|
|
|
float z;
|
2024-12-24 07:27:09 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
extern "C" struct CUDAVectorEllipsoidal {
|
2025-02-07 11:47:41 +00:00
|
|
|
|
float theta;
|
|
|
|
|
float phi;
|
|
|
|
|
float Rho;
|
2024-12-24 07:27:09 +00:00
|
|
|
|
};
|
|
|
|
|
|
2025-01-06 11:56:45 +00:00
|
|
|
|
extern "C" struct CUDAComplex {
|
2025-02-07 11:47:41 +00:00
|
|
|
|
float x;
|
|
|
|
|
float y;
|
2025-01-06 11:56:45 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2025-02-07 11:47:41 +00:00
|
|
|
|
//// <20><><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
|
|
|
|
//extern __device__ cuComplex cuCexpf(cuComplex x);
|
|
|
|
|
//extern __device__ CUDAVector GPU_VectorAB(CUDAVector A, CUDAVector B);
|
|
|
|
|
//extern __device__ float GPU_VectorNorm2(CUDAVector A);
|
|
|
|
|
//extern __device__ float GPU_dotVector(CUDAVector A, CUDAVector B);
|
|
|
|
|
//extern __device__ float GPU_CosAngle_VectorA_VectorB(CUDAVector A, CUDAVector B);
|
|
|
|
|
//
|
|
|
|
|
//// <20><><EFBFBD><EFBFBD>ȫ<EFBFBD>ֺ<EFBFBD><D6BA><EFBFBD>
|
|
|
|
|
//extern __global__ void CUDA_DistanceAB(float* Ax, float* Ay, float* Az, float* Bx, float* By, float* Bz, float* R, long len);
|
|
|
|
|
//extern __global__ void CUDA_B_DistanceA(float* Ax, float* Ay, float* Az, float Bx, float By, float Bz, float* R, long len);
|
|
|
|
|
//extern __global__ void CUDA_make_VectorA_B(float sX, float sY, float sZ, float* tX, float* tY, float* tZ, float* RstX, float* RstY, float* RstZ, long len);
|
|
|
|
|
//extern __global__ void CUDA_Norm_Vector(float* Vx, float* Vy, float* Vz, float* R, long len);
|
|
|
|
|
//extern __global__ void CUDA_cosAngle_VA_AB(float* Ax, float* Ay, float* Az, float* Bx, float* By, float* Bz, float* anglecos, long len);
|
|
|
|
|
//extern __global__ void CUDA_GridPoint_Linear_Interp1(float* v, float* q, float* qv, long xlen, long qlen);
|
|
|
|
|
//extern __global__ void CUDA_D_sin(double* y, double* X, int n);
|
|
|
|
|
//extern __global__ void CUDA_D_cos(double* y, double* X, int n);
|
|
|
|
|
//extern __global__ void CUDAKernel_MemsetBlock(cuComplex* data, cuComplex init0, long len);
|
|
|
|
|
//
|
|
|
|
|
//extern __global__ void CUDAKernel_MemsetBlock(float* data, float init0, long len);
|
2025-01-15 10:48:43 +00:00
|
|
|
|
|
|
|
|
|
|
2025-02-06 13:18:25 +00:00
|
|
|
|
// <20><>ӡGPU<50><55><EFBFBD><EFBFBD>
|
2025-02-07 11:47:41 +00:00
|
|
|
|
extern "C" GPUBASELIBAPI void printDeviceInfo(int deviceId);
|
2024-12-24 07:27:09 +00:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EEB4A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2025-02-07 11:47:41 +00:00
|
|
|
|
extern "C" GPUBASELIBAPI void checkCudaError(cudaError_t err, const char* msg);
|
2024-12-24 07:27:09 +00:00
|
|
|
|
|
|
|
|
|
// GPU <20>ڴ溯<DAB4><E6BAAF>
|
2025-02-07 11:47:41 +00:00
|
|
|
|
extern "C" GPUBASELIBAPI void* mallocCUDAHost(long memsize); // <20><><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
extern "C" GPUBASELIBAPI void FreeCUDAHost(void* ptr);
|
|
|
|
|
extern "C" GPUBASELIBAPI void* mallocCUDADevice(long memsize); // GPU<50>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
extern "C" GPUBASELIBAPI void FreeCUDADevice(void* ptr);
|
|
|
|
|
extern "C" GPUBASELIBAPI void HostToDevice(void* hostptr, void* deviceptr, long memsize);//GPU <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA> <20>豸 -> GPU
|
|
|
|
|
extern "C" GPUBASELIBAPI void DeviceToHost(void* hostptr, void* deviceptr, long memsize);//GPU <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA> GPU -> <20>豸
|
|
|
|
|
extern "C" GPUBASELIBAPI void DeviceToDevice(void* s_deviceptr, void* t_deviceptr, long memsize);//GPU <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA> GPU -> <20>豸
|
|
|
|
|
|
|
|
|
|
extern "C" GPUBASELIBAPI void CUDA_MemsetBlock(cuComplex* data, cuComplex init0, long len);
|
2024-12-27 17:08:08 +00:00
|
|
|
|
// ʸ<><CAB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㺯<EFBFBD><E3BAAF>
|
2025-02-07 11:47:41 +00:00
|
|
|
|
extern "C" GPUBASELIBAPI void CUDAdistanceAB(float* Ax, float* Ay, float* Az, float* Bx, float* By, float* Bz, float* R, long member);
|
|
|
|
|
extern "C" GPUBASELIBAPI void CUDABdistanceAs(float* Ax, float* Ay, float* Az, float Bx, float By, float Bz, float* R, long member);
|
|
|
|
|
extern "C" GPUBASELIBAPI void CUDAmake_VectorA_B(float sX, float sY, float sZ, float* tX, float* tY, float* tZ, float* RstX, float* RstY, float* RstZ, long member);
|
|
|
|
|
extern "C" GPUBASELIBAPI void CUDANorm_Vector(float* Vx, float* Vy, float* Vz, float* R, long member);
|
|
|
|
|
extern "C" GPUBASELIBAPI void CUDAcosAngle_VA_AB(float* Ax, float* Ay, float* Az, float* Bx, float* By, float* Bz, float* anglecos, long len);
|
2024-12-24 07:27:09 +00:00
|
|
|
|
|
2024-12-27 17:08:08 +00:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>㷨
|
|
|
|
|
|
2025-02-07 11:47:41 +00:00
|
|
|
|
extern "C" GPUBASELIBAPI void CUDAGridPointLinearInterp1(float* v, float* q, float* qv, long xlen, long qlen);
|
|
|
|
|
extern "C" GPUBASELIBAPI void CUDADSin(double* y, double* X, int n);
|
|
|
|
|
extern "C" GPUBASELIBAPI void CUDADCos(double* y, double* X, int n);
|
2025-01-20 07:49:54 +00:00
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD><D6BF><EFBFBD><EFBFBD><EFBFBD>
|
2025-02-07 11:47:41 +00:00
|
|
|
|
extern "C" GPUBASELIBAPI long NextBlockPad(long num, long blocksize);
|
2025-01-20 07:49:54 +00:00
|
|
|
|
|
|
|
|
|
|
2025-02-07 11:47:41 +00:00
|
|
|
|
extern "C" GPUBASELIBAPI void PrintLasterError(const char* s);
|
2025-01-20 07:49:54 +00:00
|
|
|
|
|
|
|
|
|
|
2025-02-25 05:18:19 +00:00
|
|
|
|
extern "C" GPUBASELIBAPI void CUDAIFFTScale(cuComplex* inArr, cuComplex* outArr,long InRowCount,long InColCount,long outColCount);
|
|
|
|
|
|
|
|
|
|
extern "C" GPUBASELIBAPI void CUDAIFFT(cuComplex* inArr, cuComplex* outArr, long InRowCount, long InColCount, long outColCount);
|
|
|
|
|
|
|
|
|
|
|
2024-12-24 07:27:09 +00:00
|
|
|
|
#endif
|
|
|
|
|
#endif
|