Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cuda-hello-world
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Andreas Herten
cuda-hello-world
Commits
dfda85df
Commit
dfda85df
authored
Jan 25, 2017
by
Andreas Herten
Browse files
Options
Downloads
Patches
Plain Diff
Add CUDA macro, add Makefile and syncfile
parent
c061b443
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
.sync.toml
+11
-0
11 additions, 0 deletions
.sync.toml
Makefile
+10
-0
10 additions, 0 deletions
Makefile
hello-world.cu
+24
-7
24 additions, 7 deletions
hello-world.cu
with
45 additions
and
7 deletions
.sync.toml
0 → 100644
+
11
−
0
View file @
dfda85df
# This file steers synchronization of the current folder with different target machines
# See https://github.com/AndiH/simpler-rsync for more information
[juhydra]
hostname
=
"juhydra"
target_folder
=
"~/TMP/CUDA-Hello-World/"
[juron]
hostname
=
"juron"
target_folder
=
"~/TMP/JURON/CUDA-Hello-World"
default
=
true
This diff is collapsed.
Click to expand it.
Makefile
0 → 100644
+
10
−
0
View file @
dfda85df
NVCC
=
nvcc
hello-world
:
hello-world.cu Makefile
$(
NVCC
)
-o
hello-world hello-world.cu
.PHONY
:
clean run
clean
:
rm
hello-world
run
:
hello-world
bsub
-R
"rusage[ngpus_shared=20]"
-I
./hello-world
This diff is collapsed.
Click to expand it.
hello-world.cu
+
24
−
7
View file @
dfda85df
...
@@ -6,6 +6,23 @@
...
@@ -6,6 +6,23 @@
// nvcc hello-world.cu -L /usr/local/cuda/lib -lcudart -o hello-world
// nvcc hello-world.cu -L /usr/local/cuda/lib -lcudart -o hello-world
//Macro for checking cuda errors
// #define CUDA_CALL(call) { \
// cudaError_t e = call; \
// if(e != cudaSuccess) { \
// printf("Cuda failure %s:%d: '%s' in %s\n", __FILE__, __LINE__, cudaGetErrorString(e), #call); \
// exit(0); \
// } \
// }
#include
<iostream>
#define CUDA_CALL( call ) \
{ \
cudaError_t result = call; \
if ( cudaSuccess != result ) \
std::cerr << "CUDA error " << result << " in " << __FILE__ << ":" << __LINE__ << ": " << cudaGetErrorString( result ) << " (" << #call << ")" << std::endl; \
}
#include
<stdio.h>
#include
<stdio.h>
const
int
N
=
16
;
const
int
N
=
16
;
...
@@ -29,17 +46,17 @@ int main()
...
@@ -29,17 +46,17 @@ int main()
printf
(
"%s"
,
a
);
printf
(
"%s"
,
a
);
cudaMalloc
(
(
void
**
)
&
ad
,
csize
);
CUDA_CALL
(
cudaMalloc
(
(
void
**
)
&
ad
,
csize
);
)
cudaMalloc
(
(
void
**
)
&
bd
,
isize
);
CUDA_CALL
(
cudaMalloc
(
(
void
**
)
&
bd
,
isize
);
)
cudaMemcpy
(
ad
,
a
,
csize
,
cudaMemcpyHostToDevice
);
CUDA_CALL
(
cudaMemcpy
(
ad
,
a
,
csize
,
cudaMemcpyHostToDevice
);
)
cudaMemcpy
(
bd
,
b
,
isize
,
cudaMemcpyHostToDevice
);
CUDA_CALL
(
cudaMemcpy
(
bd
,
b
,
isize
,
cudaMemcpyHostToDevice
);
)
dim3
dimBlock
(
blocksize
,
1
);
dim3
dimBlock
(
blocksize
,
1
);
dim3
dimGrid
(
1
,
1
);
dim3
dimGrid
(
1
,
1
);
hello
<<<
dimGrid
,
dimBlock
>>>
(
ad
,
bd
);
hello
<<<
dimGrid
,
dimBlock
>>>
(
ad
,
bd
);
cudaMemcpy
(
a
,
ad
,
csize
,
cudaMemcpyDeviceToHost
);
CUDA_CALL
(
cudaMemcpy
(
a
,
ad
,
csize
,
cudaMemcpyDeviceToHost
);
)
cudaFree
(
ad
);
CUDA_CALL
(
cudaFree
(
ad
);
)
cudaFree
(
bd
);
CUDA_CALL
(
cudaFree
(
bd
);
)
printf
(
"%s
\n
"
,
a
);
printf
(
"%s
\n
"
,
a
);
// sleep(1);
// sleep(1);
...
...
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
sign in
to comment