Openholo  v2.1
Open Source Digital Holographic Library
ophTriMesh_GPU.h
Go to the documentation of this file.
1 /*M///////////////////////////////////////////////////////////////////////////////////////
2 //
3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4 //
5 // By downloading, copying, installing or using the software you agree to this license.
6 // If you do not agree to this license, do not download, install, copy or use the software.
7 //
8 //
9 // License Agreement
10 // For Open Source Digital Holographic Library
11 //
12 // Openholo library is free software;
13 // you can redistribute it and/or modify it under the terms of the BSD 2-Clause license.
14 //
15 // Copyright (C) 2017-2024, Korea Electronics Technology Institute. All rights reserved.
16 // E-mail : contact.openholo@gmail.com
17 // Web : http://www.openholo.org
18 //
19 // Redistribution and use in source and binary forms, with or without modification,
20 // are permitted provided that the following conditions are met:
21 //
22 // 1. Redistribution's of source code must retain the above copyright notice,
23 // this list of conditions and the following disclaimer.
24 //
25 // 2. Redistribution's in binary form must reproduce the above copyright notice,
26 // this list of conditions and the following disclaimer in the documentation
27 // and/or other materials provided with the distribution.
28 //
29 // This software is provided by the copyright holders and contributors "as is" and
30 // any express or implied warranties, including, but not limited to, the implied
31 // warranties of merchantability and fitness for a particular purpose are disclaimed.
32 // In no event shall the copyright holder or contributors be liable for any direct,
33 // indirect, incidental, special, exemplary, or consequential damages
34 // (including, but not limited to, procurement of substitute goods or services;
35 // loss of use, data, or profits; or business interruption) however caused
36 // and on any theory of liability, whether in contract, strict liability,
37 // or tort (including negligence or otherwise) arising in any way out of
38 // the use of this software, even if advised of the possibility of such damage.
39 //
40 // This software contains opensource software released under GNU Generic Public License,
41 // NVDIA Software License Agreement, or CUDA supplement to Software License Agreement.
42 // Check whether software you use contains licensed software.
43 //
44 //M*/
45 
46 #ifndef __ophTriMesh_GPU_h
47 #define __ophTriMesh_GPU_h
48 
49 #include "ophTriMesh.h"
50 
51 #include "sys.h"
52 #include <stdio.h>
53 #include <cuda_runtime.h>
54 #include <cufft.h>
55 #include <curand.h>
56 #include <math_constants.h>
57 
58 
59 static void HandleError(cudaError_t err,
60  const char *file,
61  int line) {
62  if (err != cudaSuccess) {
63  printf("%s in %s at line %d\n", cudaGetErrorString(err),
64  file, line);
65  exit(EXIT_FAILURE);
66  }
67 }
68 #define HANDLE_ERROR( err ) (HandleError( err, __FILE__, __LINE__ ))
69 
70 
71 #define HANDLE_NULL( a ) {if (a == NULL) { \
72  printf( "Host memory failed in %s at line %d\n", __FILE__, __LINE__ ); \
73  exit( EXIT_FAILURE );}}
74 
75 #define CUDA_CALL(x) { if((x)!=cudaSuccess) { \
76  printf("Error at %s:%d\n",__FILE__,__LINE__);\
77  exit( EXIT_FAILURE ); }}
78 #define CURAND_CALL(x) { if((x)!=CURAND_STATUS_SUCCESS) { \
79  printf("Error at %s:%d\n",__FILE__,__LINE__);\
80  exit( EXIT_FAILURE ); }}
81 
82 cufftDoubleComplex *angularSpectrum_GPU;
83 cufftDoubleComplex *ffttemp;
84 
85 cudaStream_t streamTriMesh;
86 
87 extern "C"
88 {
89  void call_cudaKernel_refAS(cufftDoubleComplex* output, int nx, int ny, double px, double py, unsigned int SHADING_FLAG, int idx,
90  double waveLength, double pi, double shadingFactor, double av0, double av1, double av2,
91  double glRot0, double glRot1, double glRot2, double glRot3, double glRot4, double glRot5, double glRot6, double glRot7, double glRot8,
92  double loRot0, double loRot1, double loRot2, double loRot3, double glShiftX, double glShiftY, double glShiftZ,
93  double carrierWaveX, double carrierWaveY, double carrierWaveZ, double min_double, double tolerence, CUstream_st* streamTriMesh);
94 
95  void call_cudaKernel_refASf(cuFloatComplex* output, int nx, int ny, float px, float py, unsigned int sflag, int idx, float waveLength,
96  float pi, float shadingFactor, float av0, float av1, float av2,
97  float glRot0, float glRot1, float glRot2, float glRot3, float glRot4, float glRot5, float glRot6, float glRot7, float glRot8,
98  float loRot0, float loRot1, float loRot2, float loRot3, float glShiftX, float glShiftY, float glShiftZ,
99  float carrierWaveX, float carrierWaveY, float carrierWaveZ, float min_double, float tolerence, CUstream_st* streamTriMesh);
100 
101  void call_fftGPU(int nx, int ny, cufftDoubleComplex* input, cufftDoubleComplex* output, CUstream_st* streamTriMesh);
102  void call_fftGPUf(int nx, int ny, cuFloatComplex* input, cuFloatComplex* output, CUstream_st* streamTriMesh);
103 
104 }
105 
106 #endif
cufftDoubleComplex * angularSpectrum_GPU
void call_cudaKernel_refAS(cufftDoubleComplex *output, int nx, int ny, double px, double py, unsigned int SHADING_FLAG, int idx, double waveLength, double pi, double shadingFactor, double av0, double av1, double av2, double glRot0, double glRot1, double glRot2, double glRot3, double glRot4, double glRot5, double glRot6, double glRot7, double glRot8, double loRot0, double loRot1, double loRot2, double loRot3, double glShiftX, double glShiftY, double glShiftZ, double carrierWaveX, double carrierWaveY, double carrierWaveZ, double min_double, double tolerence, CUstream_st *streamTriMesh)
void call_fftGPUf(int nx, int ny, cuFloatComplex *input, cuFloatComplex *output, CUstream_st *streamTriMesh)
void call_fftGPU(int nx, int ny, cufftDoubleComplex *input, cufftDoubleComplex *output, CUstream_st *streamTriMesh)
cudaStream_t streamTriMesh
void call_cudaKernel_refASf(cuFloatComplex *output, int nx, int ny, float px, float py, unsigned int sflag, int idx, float waveLength, float pi, float shadingFactor, float av0, float av1, float av2, float glRot0, float glRot1, float glRot2, float glRot3, float glRot4, float glRot5, float glRot6, float glRot7, float glRot8, float loRot0, float loRot1, float loRot2, float loRot3, float glShiftX, float glShiftY, float glShiftZ, float carrierWaveX, float carrierWaveY, float carrierWaveZ, float min_double, float tolerence, CUstream_st *streamTriMesh)
cufftDoubleComplex * ffttemp