Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
cuda_lab
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Gaurav Kukreja
cuda_lab
Commits
426a5e2e
Commit
426a5e2e
authored
Mar 08, 2014
by
Gaurav Kukreja
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/gkernel/cuda_lab
parents
0030c87d
3844b5e2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
10 deletions
+27
-10
main.cu
submission/ex11/main.cu
+5
-5
main.cu
submission/ex12/main.cu
+22
-5
No files found.
submission/ex11/main.cu
View file @
426a5e2e
...
...
@@ -68,7 +68,7 @@ __global__ void compute_P(float *image, float *Px, float *Py, int w, int h, int
float G2 = 0;
for (int c = 0; c < nc; c++) {
int i = x +
w*y +
w*h*c;
int i = x +
(size_t)w*y + (size_t)
w*h*c;
float ux = ((x < w-1) ? (image[i + 1] - image[i]) : 0);
float uy = ((y < h-1) ? (image[i + w] - image[i]) : 0);
sh_u[b + B*c + B*nc*0] = ux;
...
...
@@ -78,7 +78,7 @@ __global__ void compute_P(float *image, float *Px, float *Py, int w, int h, int
float g = huber(sqrtf(G2), epsilon);
for (int c = 0; c < nc; c++) {
int i = x +
w*y +
w*h*c;
int i = x +
(size_t)w*y + (size_t)
w*h*c;
Px[i] = g * sh_u[b + B*c + B*nc*0];
Py[i] = g * sh_u[b + B*c + B*nc*1];
}
...
...
@@ -91,9 +91,9 @@ __global__ void divergence_and_update(float *image, float *Px, float *Py, int w,
int y = threadIdx.y + blockDim.y * blockIdx.y;
if (x < w && y < h) {
for (int c = 0; c < nc; c++) {
int i = x +
w*y +
w*h*c;
float dx_u1 =
Px[i]
- ((x > 0) ? Px[i - 1] : 0);
float dy_u2 =
Py[i]
- ((y > 0) ? Py[i - w] : 0);
int i = x +
(size_t)w*y + (size_t)
w*h*c;
float dx_u1 =
((x+1 < w) ? Px[i] : 0)
- ((x > 0) ? Px[i - 1] : 0);
float dy_u2 =
((y+1 < h) ? Py[i] : 0)
- ((y > 0) ? Py[i - w] : 0);
image[i] += tau * (dx_u1 + dy_u2);
}
}
...
...
submission/ex12/main.cu
View file @
426a5e2e
...
...
@@ -34,6 +34,14 @@ using namespace std;
#define USING_GPU
int min_pixels( int a, int b) {
if ( a < b ) {
return a;
} else {
return b;
}
}
__host__ __device__ float absolute_value ( float2 z ) {
return sqrtf((z.x * z.x) + (z.y * z.y));
}
...
...
@@ -51,11 +59,18 @@ __global__ void callKernel(float* imgOut, int width, int height, float2 center,
int iy = blockIdx.y * blockDim.y + threadIdx.y; // WIDTH
int ix = blockIdx.x * blockDim.x + threadIdx.x; // HEIGHT
int idx = iy * width + ix;
if(ix >= width || iy >= height) return;
int size;
if ( width < height ) {
size = width;
} else {
size = height;
}
float2 c, z;
c.x = ((float)
ix / width
) * (2.0f * radius) + center.x - radius;
c.y = ((float)
iy / height
) * (2.0f * radius) + center.y - radius;
c.x = ((float)
(ix - ((width - size)/2.0f)) / size
) * (2.0f * radius) + center.x - radius;
c.y = ((float)
(iy - ((height - size)/2.0f)) / size
) * (2.0f * radius) + center.y - radius;
z = c;
int n = 0;
while( (absolute_value(z) < 2.0f) && (n < iterations))
...
...
@@ -91,11 +106,13 @@ int main(int argc, char **argv)
getParam("height", height, argc, argv);
cout << "height = " << height<< endl;
float2 center = {-0.5f, 0.0f};
// float2 center = {-0.5f, 0.0f};
float2 center = {-0.773f, 0.1175f};
// getParam("center", center, argc, argv);
// cout << "center = " << center.x << ", " << center.y << endl;
float radius = 1.5f;
// float radius = 1.5f;
float radius = 0.005f;
getParam("radius", radius, argc, argv);
cout << "radius = " << radius << endl;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment