Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
QuickSched
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
QuickSched
Commits
6b55fd92
Commit
6b55fd92
authored
8 years ago
by
Aidan Chalk
Browse files
Options
Downloads
Patches
Plain Diff
Updated test_n2
parent
86dea08e
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
fortran_examples/test_n2.F90
+67
-11
67 additions, 11 deletions
fortran_examples/test_n2.F90
with
67 additions
and
11 deletions
fortran_examples/test_n2.F90
+
67
−
11
View file @
6b55fd92
...
@@ -39,8 +39,50 @@ Type(Cell), Dimension(:), Allocatable :: cells
...
@@ -39,8 +39,50 @@ Type(Cell), Dimension(:), Allocatable :: cells
Contains
Contains
Subroutine
Interact_single
(
cell_i
)
Subroutine
Interact_single
(
cell_i
)
Integer
,
Intent
(
in
)
::
cell_i
Integer
::
i
,
j
Integer
::
i
,
j
Real
(
Kind
=
dp
)
::
xx
,
yy
,
zz
,
r
,
f
,
ir
,
ir6
,
ir12
,
fxx
,
fyy
,
fzz
,
fix
,
fiy
,
fiz
do
i
=
1
,
cells
(
cell_i
)
%
num_parts
fix
=
0.0_dp
fiy
=
0.0_dp
fiz
=
0.0_dp
do
j
=
i
+1
,
cells
(
cell_i
)
%
num_parts
xx
=
cells
(
cell_i
)
%
dx
(
i
)
-
cells
(
cell_i
)
%
dx
(
j
)
yy
=
cells
(
cell_i
)
%
dy
(
i
)
-
cells
(
cell_i
)
%
dy
(
j
)
zz
=
cells
(
cell_i
)
%
dz
(
i
)
-
cells
(
cell_i
)
%
dz
(
j
)
r
=
xx
*
xx
+
yy
*
yy
+
zz
*
zz
r
=
sqrt
(
r
)
ir
=
0.1_dp
/
r
ir6
=
ir
*
ir
ir6
=
ir6
*
ir6
*
ir6
ir12
=
ir6
*
ir6
f
=
4.0_dp
*
(
ir12
-
ir6
)
fxx
=
f
*
xx
fyy
=
f
*
yy
fzz
=
f
*
zz
fix
=
fix
+
fxx
fiy
=
fiy
+
fyy
fiz
=
fiz
+
fzz
cells
(
cell_i
)
%
fx
(
j
)
=
cells
(
cell_i
)
%
fx
(
j
)
-
fxx
cells
(
cell_i
)
%
fy
(
j
)
=
cells
(
cell_i
)
%
fy
(
j
)
-
fyy
cells
(
cell_i
)
%
fz
(
j
)
=
cells
(
cell_i
)
%
fz
(
j
)
-
fzz
end
do
cells
(
cell_i
)
%
fx
(
i
)
=
cells
(
cell_i
)
%
fx
(
i
)
+
fix
cells
(
cell_i
)
%
fy
(
i
)
=
cells
(
cell_i
)
%
fy
(
i
)
+
fiy
cells
(
cell_i
)
%
fz
(
i
)
=
cells
(
cell_i
)
%
fz
(
i
)
+
fiz
end
do
End
Subroutine
End
Subroutine
Subroutine
Interact
(
cell_i
,
cell_j
)
Subroutine
Interact
(
cell_i
,
cell_j
)
...
@@ -107,9 +149,9 @@ Call Random_Number(cells(cell_num)%dx)
...
@@ -107,9 +149,9 @@ Call Random_Number(cells(cell_num)%dx)
Call
Random_Number
(
cells
(
cell_num
)
%
dy
)
Call
Random_Number
(
cells
(
cell_num
)
%
dy
)
Call
Random_Number
(
cells
(
cell_num
)
%
dz
)
Call
Random_Number
(
cells
(
cell_num
)
%
dz
)
dx
=
dx
*
10.0_dp
cells
(
cell_num
)
%
dx
=
cells
(
cell_num
)
%
dx
*
10.0_dp
dy
=
dy
*
10.0_dp
cells
(
cell_num
)
%
dy
=
cells
(
cell_num
)
%
dy
*
10.0_dp
dz
=
dz
*
10.0_dp
cells
(
cell_num
)
%
dz
=
cells
(
cell_num
)
%
dz
*
10.0_dp
End
Subroutine
init_cells
End
Subroutine
init_cells
...
@@ -125,7 +167,7 @@ Integer(Kind=C_INT), Pointer :: c(:)
...
@@ -125,7 +167,7 @@ Integer(Kind=C_INT), Pointer :: c(:)
call
c_f_pointer
(
data
,
c
,
[
2
])
call
c_f_pointer
(
data
,
c
,
[
2
])
If
(
typ
==
type_self
)
then
If
(
typ
==
type_self
)
then
call
Interact_self
(
c
(
1
))
else
else
call
Interact
(
c
(
1
),
c
(
2
))
call
Interact
(
c
(
1
),
c
(
2
))
end
if
end
if
...
@@ -139,12 +181,17 @@ Program main
...
@@ -139,12 +181,17 @@ Program main
Use
,
Intrinsic
::
ISO_C_BINDING
Use
,
Intrinsic
::
ISO_C_BINDING
Use
quicksched
Use
quicksched
Use
parts
Use
parts
Use
omp_lib
Implicit
None
Implicit
None
Integer
(
Kind
=
C_INT
)
::
i
,
j
,
temp
Integer
(
Kind
=
C_INT
)
::
i
,
j
,
temp
Type
(
C_PTR
)
::
sched
Type
(
C_PTR
)
::
sched
Integer
(
Kind
=
C_INT
),
Target
::
data
(
0
:
10
)
Integer
(
Kind
=
C_INT
),
Target
::
data
(
0
:
10
)
Type
(
C_PTR
)
::
d
t
a_ptr
Type
(
C_PTR
)
::
da
t
_ptr
Integer
(
Kind
=
C_INT
),
Dimension
(
1
:
1000
)
::
cell_res
Integer
(
Kind
=
C_INT
),
Dimension
(
1
:
1000
)
::
cell_res
Type
(
C_FUNPTR
)
::
runner_func
Double Precision
::
t_start
,
t_total
runner_func
=
C_FUNLOC
(
runner
)
Allocate
(
cells
(
1
:
1000
))
Allocate
(
cells
(
1
:
1000
))
do
i
=
1
,
1000
do
i
=
1
,
1000
...
@@ -152,23 +199,32 @@ do i = 1, 1000
...
@@ -152,23 +199,32 @@ do i = 1, 1000
end
do
end
do
sched
=
f_qsched_create
()
sched
=
f_qsched_create
()
call
qsched_init
(
q
sched
,
24
,
0
)
call
qsched_init
(
sched
,
24
,
0
)
do
i
=
1
,
1000
do
i
=
1
,
1000
cell_res
(
i
)
=
qsched_addres
(
q
sched
,
qsched_owner_none
,
qsched_res_none
)
cell_res
(
i
)
=
qsched_addres
(
sched
,
qsched_owner_none
,
qsched_res_none
)
end
do
end
do
do
i
=
1
,
1000
do
i
=
1
,
1000
data
data
(
0
)
=
i
temp
=
qsched_addtask
(
sched
,
type_self
,
0
,
C_LOC
(
data
(
0
)),
int
(
c_sizeof
(
type_self
),
C_INT
),
1
)
call
qsched_addlock
(
sched
,
temp
,
cell_res
(
i
))
do
j
=
i
+1
,
1000
do
j
=
i
+1
,
1000
data
(
1
)
=
j
temp
=
qsched_addtask
(
sched
,
type_pair
,
0
,
C_LOC
(
data
(
0
)),
int
(
c_sizeof
(
type_self
)
*
2
,
C_INT
),
1
)
call
qsched_addlock
(
sched
,
temp
,
cell_res
(
i
))
call
qsched_addlock
(
sched
,
temp
,
cell_res
(
j
))
end
do
end
do
end
do
end
do
t_start
=
omp_get_wtime
()
call
qsched_run
(
sched
,
24
,
runner_func
)
t_total
=
omp_get_wtime
()
-
t_start
print
*
,
"Took"
,
t_total
call
qsched_free
(
sched
)
call
f_qsched_destroy
(
sched
)
end
Program
end
Program
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