Commit 6ada84481a465afbcf89895b5bed0e74e08742e0

Authored by Pavel Govyadinov
1 parent 0730bd04

Reverted to 40db18bb the hard way, by overwriting the old files and pushing

stim/cuda/cuda_texture.cuh
... ... @@ -134,15 +134,15 @@ namespace stim
134 134 void
135 135 UnmapCudaTexture()
136 136 {
137   - HANDLE_ERROR(
138   - cudaGraphicsUnmapResources(1, &resource)
139   - );
140   - HANDLE_ERROR(
141   - cudaGraphicsUnregisterResource(resource)
142   - );
143   - HANDLE_ERROR(
144   - cudaDestroyTextureObject(tObj)
145   - );
  137 + // HANDLE_ERROR(
  138 + // cudaGraphicsUnmapResources(1, &resource)
  139 + // );
  140 + // HANDLE_ERROR(
  141 + // cudaGraphicsUnregisterResource(resource)
  142 + // );
  143 + // HANDLE_ERROR(
  144 + // cudaDestroyTextureObject(tObj)
  145 + // );
146 146 // HANDLE_ERROR(
147 147 // cudaFreeArray(srcArray)
148 148 // );
... ...
stim/cuda/filter.cuh
... ... @@ -7,6 +7,7 @@
7 7 #include <stdio.h>
8 8 #include <stim/visualization/colormap.h>
9 9 #include <sstream>
  10 +#include <stim/math/constants.h>
10 11 #include <stim/cuda/cudatools/devices.h>
11 12 #include <stim/cuda/cudatools/threads.h>
12 13 #include <stim/cuda/cuda_texture.cuh>
... ... @@ -14,7 +15,6 @@
14 15 #include <stim/cuda/arraymath.cuh>
15 16  
16 17 #define IMAD(a,b,c) ( __mul24((a), (b)) + (c) )
17   -#define M_PI 3.141592654f
18 18  
19 19  
20 20 namespace stim
... ... @@ -73,7 +73,7 @@ namespace stim
73 73 idx = j*kl+i;
74 74 x = i - kr - 0.5;
75 75 y = j - kr - 0.5;
76   - LoG[idx] = (-1.0/M_PI/powf(sigma, 4))* (1 - (powf(x,2)+powf(y,2))/2.0/powf(sigma, 2))
  76 + LoG[idx] = (-1.0/PI/powf(sigma, 4))* (1 - (powf(x,2)+powf(y,2))/2.0/powf(sigma, 2))
77 77 *expf(-(powf(x,2)+powf(y,2))/2/powf(sigma,2));
78 78 t +=LoG[idx];
79 79 }
... ... @@ -98,7 +98,7 @@ namespace stim
98 98 int y = blockIdx.y;
99 99 int xi = threadIdx.x;
100 100 int yi = threadIdx.y;
101   - float val = 0;
  101 + // float val = 0;
102 102 float tu = (x-kr+xi)/(float)DIM_X;
103 103 float tv = (y-kr+yi)/(float)DIM_Y;
104 104 shared[xi][yi] = gpuLoG[yi*kl+xi]*(255.0-(float)tex2D<unsigned char>(texIn, tu, tv));
... ... @@ -111,7 +111,7 @@ namespace stim
111 111 //y = min(y, height - 1);
112 112  
113 113 int idx = y*DIM_X+x;
114   - int k_idx;
  114 + // int k_idx;
115 115 for(unsigned int step = blockDim.x/2; step >= 1; step >>= 1)
116 116 {
117 117 __syncthreads();
... ...
stim/cuda/ivote/down_sample.cuh
... ... @@ -44,7 +44,7 @@ namespace stim{
44 44 unsigned int y_ds = (y/sigma_ds + (y %sigma_ds == 0 ? 0:1));
45 45  
46 46 //get the number of pixels in the image
47   - unsigned int pixels_ds = x_ds * y_ds;
  47 +// unsigned int pixels_ds = x_ds * y_ds;
48 48  
49 49 unsigned int max_threads = stim::maxThreadsPerBlock();
50 50 dim3 threads(max_threads, 1);
... ... @@ -97,4 +97,4 @@ namespace stim{
97 97 }
98 98 }
99 99  
100   -#endif
101 100 \ No newline at end of file
  101 +#endif
... ...
stim/gl/gl_spider.h
... ... @@ -14,6 +14,7 @@
14 14 #include <stim/math/vec3.h>
15 15 #include <stim/math/rect.h>
16 16 #include <stim/math/matrix.h>
  17 +#include <stim/math/constants.h>
17 18 #include <stim/cuda/spider_cost.cuh>
18 19 #include <stim/cuda/cudatools/glbind.h>
19 20 #include <stim/cuda/arraymath.cuh>
... ... @@ -369,7 +370,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
369 370 ///Stored in a display list.
370 371 ///uses the default d vector <0,0,1>
371 372 void
372   - genDirectionVectors(float solidAngle = 5/M_PI*4)
  373 + genDirectionVectors(float solidAngle = M_PI/2)
373 374 {
374 375  
375 376 //Set up the vectors necessary for Rectangle creation.
... ... @@ -584,7 +585,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
584 585 glDeleteFramebuffers(1, &framebufferID);
585 586 glGenFramebuffers(1, &framebufferID);
586 587 glBindFramebuffer(GL_FRAMEBUFFER, framebufferID);
587   - int numChannels = 1;
  588 +// int numChannels = 1;
588 589 // unsigned char* texels = new unsigned char[width * height * numChannels];
589 590 glGenTextures(1, &textureID);
590 591 glBindTexture(GL_TEXTURE_2D, textureID);
... ... @@ -609,7 +610,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
609 610 {
610 611 glGenFramebuffers(1, &fboID);
611 612 glBindFramebuffer(GL_FRAMEBUFFER, fboID);
612   - int numChannels = 1;
  613 +// int numChannels = 1;
613 614 // unsigned char* texels = new unsigned char[width * height * numChannels];
614 615 glGenTextures(1, &texbufferID);
615 616 glBindTexture(GL_TEXTURE_2D, texbufferID);
... ... @@ -938,7 +939,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
938 939 network_time = 0;
939 940 hit_time = 0;
940 941 #endif
941   - stepsize = 3.0;
  942 + stepsize = 2.5;
942 943 t_length = 16.0;
943 944  
944 945 srand(100);
... ... @@ -1392,13 +1393,9 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1392 1393  
1393 1394 Z[0] = cos(PHI[0]);
1394 1395 Z[1] = cos(PHI[1]);
1395   -
1396 1396  
1397 1397 range = Z[0] - Z[1];
1398 1398  
1399   -
1400   - float z, theta, phi;
1401   -
1402 1399 std::vector<stim::vec3<float> > vecsUni;
1403 1400 for(int i = 0; i < numSamplesPos; i++)
1404 1401 {
... ... @@ -1490,8 +1487,6 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1490 1487 void
1491 1488 trace(int min_cost)
1492 1489 {
1493   - bool sEmpty = true;
1494   - float lastmag = 16.0;;
1495 1490 stim::vec3<float> curSeed;
1496 1491 stim::vec3<float> curSeedVec;
1497 1492 float curSeedMag;
... ... @@ -1527,7 +1522,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1527 1522 gpuStartTimer();
1528 1523 #endif
1529 1524  
1530   - float s = 3.0;
  1525 +// float s = 3.0;
1531 1526 GLuint selectBuf[2048];
1532 1527 GLint hits;
1533 1528 glSelectBuffer(2048, selectBuf);
... ... @@ -1541,17 +1536,17 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1541 1536 CHECK_OPENGL_ERROR
1542 1537 //What would that vessel see in front of it.
1543 1538 camSel.setPosition(loc);
1544   - camSel.setFocalDistance(mag/s);
1545   - camSel.LookAt((loc[0]+dir[0]*mag/s),
1546   - (loc[1]+dir[1]*mag/s),
1547   - (loc[2]+dir[2]*mag/s));
  1539 + camSel.setFocalDistance(mag/stepsize);
  1540 + camSel.LookAt((loc[0]+dir[0]*mag/stepsize),
  1541 + (loc[1]+dir[1]*mag/stepsize),
  1542 + (loc[2]+dir[2]*mag/stepsize));
1548 1543 ps = camSel.getPosition();
1549 1544 ups = camSel.getUp();
1550 1545 ds = camSel.getLookAt();
1551 1546 glMatrixMode(GL_PROJECTION);
1552 1547 glPushMatrix();
1553 1548 glLoadIdentity();
1554   - glOrtho(-mag/s/2.0, mag/s/2.0, -mag/s/2.0, mag/s/2.0, 0.0, mag/s/2.0);
  1549 + glOrtho(-mag/stepsize/2.0, mag/stepsize/2.0, -mag/stepsize/2.0, mag/stepsize/2.0, 0.0, mag/stepsize/2.0);
1555 1550 glMatrixMode(GL_MODELVIEW);
1556 1551 glPushMatrix();
1557 1552 glLoadIdentity();
... ... @@ -1597,21 +1592,11 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1597 1592 int
1598 1593 processHits(GLint hits, GLuint buffer[])
1599 1594 {
1600   - GLuint names, *ptr;
1601   - //printf("hits = %u\n", hits);
  1595 + GLuint *ptr;
1602 1596 ptr = (GLuint *) buffer;
1603   - // for (int i = 0; i < hits; i++) { /* for each hit */
1604   - names = *ptr;
1605   - // printf (" number of names for hit = %u\n", names);
1606 1597 ptr++;
1607 1598 ptr++; //Skip the minimum depth value.
1608 1599 ptr++; //Skip the maximum depth value.
1609   - // printf (" the name is ");
1610   - // for (int j = 0; j < names; j++) { /* for each name */
1611   - // printf ("%u ", *ptr); ptr++;
1612   - // }
1613   - // printf ("\n");
1614   - // }
1615 1600  
1616 1601  
1617 1602 if(hits == 0)
... ... @@ -1675,11 +1660,18 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1675 1660 }
1676 1661  
1677 1662 #ifdef TIMING
1678   - double network_time = (std::clock() - s) / (double) CLOCKS_PER_SEC;
1679   - network_time += network_time * 1000.0;
  1663 + double nt = (std::clock() - s) / (double) CLOCKS_PER_SEC;
  1664 + network_time += nt * 1000.0;
1680 1665 #endif
1681 1666 }
1682 1667  
  1668 +// void
  1669 +// addToNetwork(pair<stim::fiber<float>, int> in, stim::vec3<float> spos,
  1670 +// stim::vec<float> smag, stim::vec3<float> sdir)
  1671 +// {
  1672 +//
  1673 +// }
  1674 +
1683 1675  
1684 1676 void
1685 1677 printSizes()
... ... @@ -1783,9 +1775,6 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
1783 1775 }
1784 1776 }
1785 1777 }
1786   -
1787   -
1788   -
1789 1778 };
1790 1779 }
1791 1780 #endif
... ...
stim/math/matrix.h
... ... @@ -53,13 +53,13 @@ struct matrix
53 53  
54 54 template<typename Y>
55 55 vec<Y> operator*(vec<Y> rhs){
56   - unsigned int N = rhs.size();
  56 + unsigned int M = rhs.size();
57 57  
58 58 vec<Y> result;
59   - result.resize(N);
  59 + result.resize(M);
60 60  
61   - for(int r=0; r<N; r++)
62   - for(int c=0; c<N; c++)
  61 + for(int r=0; r<M; r++)
  62 + for(int c=0; c<M; c++)
63 63 result[r] += (*this)(r, c) * rhs[c];
64 64  
65 65 return result;
... ...