Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
OpenMP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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
Xinzhe Wu
OpenMP
Commits
289dce4d
Commit
289dce4d
authored
Sep 10, 2020
by
Xinzhe Wu
Browse files
Options
Downloads
Patches
Plain Diff
add 2 examples
parent
db422bac
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
.gitignore
+54
-0
54 additions, 0 deletions
.gitignore
0_hello_world/hello_world.cpp
+10
-0
10 additions, 0 deletions
0_hello_world/hello_world.cpp
1_integral/integral.cpp
+33
-0
33 additions, 0 deletions
1_integral/integral.cpp
with
97 additions
and
0 deletions
.gitignore
0 → 100644
+
54
−
0
View file @
289dce4d
# Prerequisites
*.d
# Compiled Object files
*.slo
*.lo
*.o
*.obj
# Precompiled Headers
*.gch
*.pch
# Compiled Dynamic libraries
*.so
*.dylib
*.dll
# Fortran module files
*.mod
*.smod
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
# Executables
*.exe
*.out
*.app
./build
./build2
build
build2
./build3
./build4
build3
build4
build_juwels
./build_juwels
CMakeLists.txt.user
CMakeCache.txt
CMakeFiles
CMakeScripts
Testing
Makefile
cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
_deps
This diff is collapsed.
Click to expand it.
0_hello_world/hello_world.cpp
0 → 100644
+
10
−
0
View file @
289dce4d
#include
<omp.h>
#include
<stdio.h>
int
main
(
int
argc
,
char
*
argv
[])
{
int
nthreads
;
#pragma omp parallel
printf
(
"Hello World from thread = [%d]
\n
"
,
omp_get_thread_num
());
}
This diff is collapsed.
Click to expand it.
1_integral/integral.cpp
0 → 100644
+
33
−
0
View file @
289dce4d
#include
<math.h>
#include
<iostream>
#include
<omp.h>
#include
<chrono>
#define from 0.0f
#define to 2.0f
#define parts 999999999
#define step ((to - from) / parts)
#define x (from + (step / 2.0f))
int
main
()
{
double
integralSum
=
0
;
int
i
;
std
::
chrono
::
high_resolution_clock
::
time_point
t1
=
std
::
chrono
::
high_resolution_clock
::
now
();
#pragma omp parallel for reduction(+:integralSum)
for
(
i
=
1
;
i
<
(
parts
+
1
);
++
i
)
{
integralSum
=
integralSum
+
(
step
*
fabs
(
pow
((
x
+
(
step
*
i
)),
2
)
+
4
));
}
std
::
chrono
::
high_resolution_clock
::
time_point
t2
=
std
::
chrono
::
high_resolution_clock
::
now
();
std
::
chrono
::
duration
<
double
>
time_span
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
duration
<
double
>>
(
t2
-
t1
);
std
::
cout
<<
"Integral sum = "
<<
integralSum
<<
", time = "
<<
time_span
.
count
()
<<
" s."
<<
std
::
endl
;
return
0
;
}
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