Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Multicore GPU programming
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ylva Selling
Multicore GPU programming
Commits
d22e26e6
Commit
d22e26e6
authored
4 years ago
by
dansa828
Browse files
Options
Downloads
Patches
Plain Diff
Lab4 updates
parent
fa04cadc
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Lab4/matrix_gpu.cu
+11
-7
11 additions, 7 deletions
Lab4/matrix_gpu.cu
with
11 additions
and
7 deletions
Lab4/matrix_gpu.cu
+
11
−
7
View file @
d22e26e6
...
...
@@ -6,17 +6,21 @@
#include
<stdio.h>
#include
<cmath>
const
int
N
=
32
;
const
int
blocksize
=
64
;
const
int
gridsize
=
4
;
const
int
N
=
1024
;
const
int
blocksize
=
32
;
//threads
const
int
gridsize
=
32
;
//blocks
__global__
void
add
(
float
*
result
,
float
*
c
,
float
*
d
)
void
add
(
float
*
result
,
float
*
c
,
float
*
d
,
int
N
)
{
int
idx
=
blockIdx
.
x
*
blockDim
.
x
+
threadIdx
.
x
;
int
idy
=
blockIdx
.
y
*
blockDim
.
y
+
threadIdx
.
y
;
int
index
=
idy
*
blockDim
.
x
+
idx
;
result
[
index
]
=
c
[
index
]
+
d
[
index
];
int
index
=
idx
+
idy
*
N
;
if
(
idx
<
N
&&
idy
<
N
)
{
result
[
index
]
=
c
[
index
]
+
d
[
index
];
}
}
int
main
()
...
...
@@ -51,7 +55,7 @@ int main()
cudaEventCreate
(
&
startEvent
);
cudaEventCreate
(
&
finEvent
);
cudaEventRecord
(
startEvent
,
0
);
add
<<<
dimGrid
,
dimBlock
>>>
(
result_cuda
,
c
,
d
);
add
<<<
dimGrid
,
dimBlock
>>>
(
result_cuda
,
c
,
d
,
N
);
cudaThreadSynchronize
();
cudaEventRecord
(
finEvent
,
0
);
cudaEventSynchronize
(
finEvent
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment