Commit 1d08c377361a8188328ff60b73a05b5e621d6b80
1 parent
288593c0
added grids subdirectory
Showing
3 changed files
with
50 additions
and
35 deletions
Show diff stats
1 | +#ifndef STIM_GRID_DATA_CUH | |
2 | +#define STIM_GRID_DATA_CUH | |
3 | + | |
4 | +#include <vector> | |
5 | +#include <string> | |
6 | +#include <sstream> | |
7 | + | |
8 | +#include "../cuda/threads.h" | |
9 | +#include "../cuda/error.h" | |
10 | +#include "../cuda/devices.h" | |
11 | + | |
12 | + | |
13 | +namespace stim{ | |
14 | + | |
15 | +//This object describes a generic D-dimensional grid containing data of type T | |
16 | + // data can be stored on the GPU or CPU (and transferred between the two) | |
17 | + // data can be loaded in the form of images | |
18 | + // data can be saved in the form of binary files | |
19 | +template<typename T, unsigned int D = 1> | |
20 | +class grid_data{ | |
21 | + | |
22 | +protected: | |
23 | + | |
24 | + unsigned long R[D]; //elements in each dimension | |
25 | + T* ptr; //pointer to the data (on the GPU or CPU) | |
26 | + bool gpu; //true if the data is on the GPU | |
27 | + | |
28 | +}; | |
29 | + | |
30 | +} | |
31 | + | |
32 | + | |
33 | +#endif | |
0 | 34 | \ No newline at end of file | ... | ... |
1 | +#ifndef STIM_IMAGE_STACK_H | |
2 | +#define STIM_IMAGE_STACK_H | |
3 | + | |
4 | + | |
5 | +namespace stim{ | |
6 | + | |
7 | +//this creates a class that can be used to load 3D grid data from stacks of images | |
8 | +template<typename T> | |
9 | +class image_stack : public virtual grid_data<T, 3>{ | |
10 | + | |
11 | +}; | |
12 | + | |
13 | + | |
14 | +} | |
15 | + | |
16 | +#endif | |
0 | 17 | \ No newline at end of file | ... | ... |
math/realfield.cuh
... | ... | @@ -8,30 +8,6 @@ |
8 | 8 | #include "cublas_v2.h" |
9 | 9 | #include <cuda_runtime.h> |
10 | 10 | |
11 | -///Compute a Gaussian function in 3D (mostly for testing) | |
12 | -/*template<typename T> | |
13 | -__global__ void gpu_gaussian(T* dest, unsigned int r0, unsigned int r1, T mean, T std, stim::rect<T> shape) | |
14 | -{ | |
15 | - int iu = blockIdx.x * blockDim.x + threadIdx.x; | |
16 | - int iv = blockIdx.y * blockDim.y + threadIdx.y; | |
17 | - | |
18 | - //make sure that the thread indices are in-bounds | |
19 | - if(iu >= r0 || iv >= r1) return; | |
20 | - | |
21 | - //compute the index into the field | |
22 | - int i = iv*r0 + iu; | |
23 | - | |
24 | - T u = (T)iu / (T)r0; | |
25 | - T v = (T)iv / (T)r1; | |
26 | - | |
27 | - stim::vec<T> p = shape(u, v); | |
28 | - | |
29 | - T fx = (T)1.0 / (std * (T)sqrt(2 * 3.14159f) ) * exp( - pow(p[0] - mean, 2) / (2 * std*std) ); | |
30 | - T fy = (T)1.0 / (std * (T)sqrt(2 * 3.14159f) ) * exp( - pow(p[1] - mean, 2) / (2 * std*std) ); | |
31 | - T fz = (T)1.0 / (std * (T)sqrt(2 * 3.14159f) ) * exp( - pow(p[2] - mean, 2) / (2 * std*std) ); | |
32 | - | |
33 | - dest[i] = fx * fy * fz; | |
34 | -}*/ | |
35 | 11 | |
36 | 12 | namespace stim{ |
37 | 13 | |
... | ... | @@ -271,19 +247,9 @@ public: |
271 | 247 | } |
272 | 248 | } |
273 | 249 | |
274 | - //std::cout<<"realfield COPY CONSTRUCTOR"<<std::endl; | |
250 | + | |
275 | 251 | } |
276 | 252 | |
277 | - /*void gaussian(P mean, P std, unsigned int n=0) //creates a 3D gaussian using component n | |
278 | - { | |
279 | - int maxThreads = stim::maxThreadsPerBlock(); //compute the optimal block size | |
280 | - int SQRT_BLOCK = (int)sqrt((float)maxThreads); | |
281 | - //create one thread for each detector pixel | |
282 | - dim3 dimBlock(SQRT_BLOCK, SQRT_BLOCK); | |
283 | - dim3 dimGrid((R[0] + SQRT_BLOCK -1)/SQRT_BLOCK, (R[1] + SQRT_BLOCK - 1)/SQRT_BLOCK); | |
284 | - | |
285 | - gpu_gaussian<float> <<<dimGrid, dimBlock>>> (X[n], R[0], R[1], mean, std, shape); | |
286 | - }*/ | |
287 | 253 | |
288 | 254 | |
289 | 255 | ... | ... |