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
8039190a
Commit
8039190a
authored
Mar 09, 2014
by
Miklós Homolya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make Gauß-Seidl into SOR
parent
da4a9c05
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
5 deletions
+10
-5
main.cu
miklos/ex13_sor/main.cu
+10
-5
No files found.
miklos/ex13_sor/main.cu
View file @
8039190a
...
...
@@ -73,7 +73,7 @@ __global__ void diffusivity(float *U, float *G, int w, int h, int nc, float epsi
}
__global__ void sor_update(float *U, float *F, float *G, int w, int h, int nc,
float lambda, int color)
float lambda,
float theta,
int color)
{
int x = threadIdx.x + blockDim.x * blockIdx.x;
int y = threadIdx.y + blockDim.y * blockIdx.y;
...
...
@@ -99,7 +99,8 @@ __global__ void sor_update(float *U, float *F, float *G, int w, int h, int nc,
if (g_d)
gu += g_d * U[j - w];
U[j] = (2 * F[j] + lambda * gu) / (2 + lambda * g);
float z = (2 * F[j] + lambda * gu) / (2 + lambda * g);
U[j] = z + theta * (z - U[j]);
}
}
}
...
...
@@ -162,7 +163,11 @@ int main(int argc, char **argv)
getParam("lambda", lambda, argc, argv);
cout << "λ: " << lambda << endl;
int N = 60;
float theta = 0.9;
getParam("theta", theta, argc, argv);
cout << "θ: " << theta << endl;
int N = 40;
getParam("N", N, argc, argv);
cout << "N: " << N << endl;
...
...
@@ -260,8 +265,8 @@ int main(int argc, char **argv)
for (int n = 0; n < N; n++) {
diffusivity<<< grid, block >>>(d_U, d_G, w, h, nc, epsilon);
sor_update<<< grid, block >>>(d_U, d_F, d_G, w, h, nc, lambda, 0);
sor_update<<< grid, block >>>(d_U, d_F, d_G, w, h, nc, lambda, 1);
sor_update<<< grid, block >>>(d_U, d_F, d_G, w, h, nc, lambda,
theta,
0);
sor_update<<< grid, block >>>(d_U, d_F, d_G, w, h, nc, lambda,
theta,
1);
}
cudaMemcpy(imgOut, d_U, imageBytes, cudaMemcpyDeviceToHost);
...
...
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