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
d0028095
Commit
d0028095
authored
11 years ago
by
Pedro Gonnet
Browse files
Options
Downloads
Patches
Plain Diff
a bit of renaming.
parent
0916038e
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
examples/mkplots_tasks.m
+2
-2
2 additions, 2 deletions
examples/mkplots_tasks.m
examples/test.c
+22
-22
22 additions, 22 deletions
examples/test.c
examples/test_bh.c
+27
-27
27 additions, 27 deletions
examples/test_bh.c
examples/test_qr.c
+27
-27
27 additions, 27 deletions
examples/test_qr.c
with
78 additions
and
78 deletions
examples/mkplots_tasks.m
+
2
−
2
View file @
d0028095
...
@@ -84,7 +84,7 @@ print -depsc2 tasks_qr_dynamic.eps
...
@@ -84,7 +84,7 @@ print -depsc2 tasks_qr_dynamic.eps
%% Plot the tiled Barnes-Hut
t
tasks
%% Plot the tiled Barnes-Hut tasks
%% Plot the task timelines for tasks allocation
%% Plot the task timelines for tasks allocation
% Load the data
% Load the data
...
@@ -112,7 +112,7 @@ hold off;
...
@@ -112,7 +112,7 @@ hold off;
xlabel
(
'time (ms)'
);
xlabel
(
'time (ms)'
);
ylabel
(
'core ID'
);
ylabel
(
'core ID'
);
set
(
gca
,
'YTick'
,
1
:(
max
(
tasks
(:,
1
))
+
1
))
set
(
gca
,
'YTick'
,
1
:(
max
(
tasks
(:,
1
))
+
1
))
title
(
'Barnes-Hut
t
tasks'
);
title
(
'Barnes-Hut tasks'
);
axis
([
0
,
max
(
tasks
(:,
3
)
+
tasks
(:,
4
)
)
,
-
0.5
,
nr_cores
-
0.5
]);
axis
([
0
,
max
(
tasks
(:,
3
)
+
tasks
(:,
4
)
)
,
-
0.5
,
nr_cores
-
0.5
]);
% Print this plot
% Print this plot
...
...
This diff is collapsed.
Click to expand it.
examples/test.c
+
22
−
22
View file @
d0028095
...
@@ -62,7 +62,7 @@ void matmul ( int m , int n , int k , double *a , int lda , double *b , int ldb
...
@@ -62,7 +62,7 @@ void matmul ( int m , int n , int k , double *a , int lda , double *b , int ldb
void
test2
(
int
m
,
int
n
,
int
k
,
int
nr_threads
)
{
void
test2
(
int
m
,
int
n
,
int
k
,
int
nr_threads
)
{
int
i
,
j
,
kk
,
qid
,
data
[
3
],
*
d
,
tid
,
rid
;
int
i
,
j
,
kk
,
qid
,
data
[
3
],
*
d
,
tid
,
rid
;
struct
sched
s
;
struct
q
sched
s
;
struct
task
*
t
;
struct
task
*
t
;
double
*
a
,
*
b
,
*
c
,
*
res
,
err
=
0
.
0
,
irm
=
1
.
0
/
RAND_MAX
;
double
*
a
,
*
b
,
*
c
,
*
res
,
err
=
0
.
0
,
irm
=
1
.
0
/
RAND_MAX
;
ticks
tic_task
,
toc_task
,
tic_ref
,
toc_ref
;
ticks
tic_task
,
toc_task
,
tic_ref
,
toc_ref
;
...
@@ -72,8 +72,8 @@ void test2 ( int m , int n , int k , int nr_threads ) {
...
@@ -72,8 +72,8 @@ void test2 ( int m , int n , int k , int nr_threads ) {
"C_ij = A_i: * B_:j, with tasks for each k where C_ij += A_ik*B_kj."
);
"C_ij = A_i: * B_:j, with tasks for each k where C_ij += A_ik*B_kj."
);
/* Init the sched. */
/* Init the sched. */
bzero
(
&
s
,
sizeof
(
struct
sched
)
);
bzero
(
&
s
,
sizeof
(
struct
q
sched
)
);
sched_init
(
&
s
,
nr_threads
,
m
*
n
);
q
sched_init
(
&
s
,
nr_threads
,
m
*
n
);
/* Allocate the matrices. */
/* Allocate the matrices. */
if
(
(
a
=
(
double
*
)
malloc
(
sizeof
(
double
)
*
m
*
k
*
32
*
32
)
)
==
NULL
||
if
(
(
a
=
(
double
*
)
malloc
(
sizeof
(
double
)
*
m
*
k
*
32
*
32
)
)
==
NULL
||
...
@@ -93,17 +93,17 @@ void test2 ( int m , int n , int k , int nr_threads ) {
...
@@ -93,17 +93,17 @@ void test2 ( int m , int n , int k , int nr_threads ) {
/* Build a task for each tile of the matrix c. */
/* Build a task for each tile of the matrix c. */
for
(
i
=
0
;
i
<
m
;
i
++
)
for
(
i
=
0
;
i
<
m
;
i
++
)
for
(
j
=
0
;
j
<
n
;
j
++
)
{
for
(
j
=
0
;
j
<
n
;
j
++
)
{
rid
=
sched_addres
(
&
s
,
-
1
);
rid
=
q
sched_addres
(
&
s
,
-
1
);
data
[
0
]
=
i
;
data
[
1
]
=
j
;
data
[
0
]
=
i
;
data
[
1
]
=
j
;
for
(
kk
=
0
;
kk
<
k
;
kk
++
)
{
for
(
kk
=
0
;
kk
<
k
;
kk
++
)
{
data
[
2
]
=
kk
;
data
[
2
]
=
kk
;
tid
=
sched_newtask
(
&
s
,
1
,
0
,
0
,
data
,
3
*
sizeof
(
int
)
,
1
);
tid
=
q
sched_newtask
(
&
s
,
1
,
task_flag_none
,
data
,
3
*
sizeof
(
int
)
,
1
);
sched_addlock
(
&
s
,
tid
,
rid
);
q
sched_addlock
(
&
s
,
tid
,
rid
);
}
}
}
}
/* Prepare the sched for execution. */
/* Prepare the sched for execution. */
sched_prepare
(
&
s
);
q
sched_prepare
(
&
s
);
/* Parallel loop. */
/* Parallel loop. */
tic_task
=
getticks
();
tic_task
=
getticks
();
...
@@ -117,13 +117,13 @@ void test2 ( int m , int n , int k , int nr_threads ) {
...
@@ -117,13 +117,13 @@ void test2 ( int m , int n , int k , int nr_threads ) {
while
(
1
)
{
while
(
1
)
{
/* Get a task, break if unsucessful. */
/* Get a task, break if unsucessful. */
if
(
(
t
=
sched_gettask
(
&
s
,
qid
)
)
==
NULL
)
if
(
(
t
=
q
sched_gettask
(
&
s
,
qid
)
)
==
NULL
)
break
;
break
;
/* Decode and execute the task. */
/* Decode and execute the task. */
switch
(
t
->
type
)
{
switch
(
t
->
type
)
{
case
1
:
case
1
:
d
=
sched_getdata
(
&
s
,
t
);
d
=
q
sched_getdata
(
&
s
,
t
);
// message( "thread %i working on block [ %i , %i ] with k=%i, lock[0]=%i." , qid , d[0] , d[1] , d[2] , t->locks[0] ); fflush(stdout);
// message( "thread %i working on block [ %i , %i ] with k=%i, lock[0]=%i." , qid , d[0] , d[1] , d[2] , t->locks[0] ); fflush(stdout);
matmul
(
32
,
32
,
32
,
&
a
[
d
[
2
]
*
32
*
m
*
32
+
d
[
0
]
*
32
]
,
m
*
32
,
&
b
[
k
*
32
*
d
[
1
]
*
32
+
d
[
2
]
*
32
]
,
k
*
32
,
&
c
[
d
[
0
]
*
32
+
m
*
32
*
d
[
1
]
*
32
]
,
m
*
32
);
matmul
(
32
,
32
,
32
,
&
a
[
d
[
2
]
*
32
*
m
*
32
+
d
[
0
]
*
32
]
,
m
*
32
,
&
b
[
k
*
32
*
d
[
1
]
*
32
+
d
[
2
]
*
32
]
,
k
*
32
,
&
c
[
d
[
0
]
*
32
+
m
*
32
*
d
[
1
]
*
32
]
,
m
*
32
);
break
;
break
;
...
@@ -132,7 +132,7 @@ void test2 ( int m , int n , int k , int nr_threads ) {
...
@@ -132,7 +132,7 @@ void test2 ( int m , int n , int k , int nr_threads ) {
}
}
/* Clean up afterwards. */
/* Clean up afterwards. */
sched_done
(
&
s
,
t
);
q
sched_done
(
&
s
,
t
);
}
/* main loop. */
}
/* main loop. */
...
@@ -158,7 +158,7 @@ void test2 ( int m , int n , int k , int nr_threads ) {
...
@@ -158,7 +158,7 @@ void test2 ( int m , int n , int k , int nr_threads ) {
} */
} */
/* Clean up. */
/* Clean up. */
sched_free
(
&
s
);
q
sched_free
(
&
s
);
free
(
a
);
free
(
a
);
free
(
b
);
free
(
b
);
free
(
c
);
free
(
c
);
...
@@ -177,7 +177,7 @@ void test2 ( int m , int n , int k , int nr_threads ) {
...
@@ -177,7 +177,7 @@ void test2 ( int m , int n , int k , int nr_threads ) {
void
test1
(
int
m
,
int
n
,
int
k
,
int
nr_threads
)
{
void
test1
(
int
m
,
int
n
,
int
k
,
int
nr_threads
)
{
int
i
,
j
,
qid
,
data
[
2
],
*
d
,
tid
,
rid
;
int
i
,
j
,
qid
,
data
[
2
],
*
d
,
tid
,
rid
;
struct
sched
s
;
struct
q
sched
s
;
struct
task
*
t
;
struct
task
*
t
;
double
*
a
,
*
b
,
*
c
,
*
res
,
err
=
0
.
0
,
irm
=
1
.
0
/
RAND_MAX
;
double
*
a
,
*
b
,
*
c
,
*
res
,
err
=
0
.
0
,
irm
=
1
.
0
/
RAND_MAX
;
ticks
tic_task
,
toc_task
,
tic_ref
,
toc_ref
;
ticks
tic_task
,
toc_task
,
tic_ref
,
toc_ref
;
...
@@ -187,8 +187,8 @@ void test1 ( int m , int n , int k , int nr_threads ) {
...
@@ -187,8 +187,8 @@ void test1 ( int m , int n , int k , int nr_threads ) {
"C_ij = A_i: * B_:j, with a single task per C_ij."
);
"C_ij = A_i: * B_:j, with a single task per C_ij."
);
/* Init the sched. */
/* Init the sched. */
bzero
(
&
s
,
sizeof
(
struct
sched
)
);
bzero
(
&
s
,
sizeof
(
struct
q
sched
)
);
sched_init
(
&
s
,
nr_threads
,
m
*
n
);
q
sched_init
(
&
s
,
nr_threads
,
m
*
n
);
/* Allocate the matrices. */
/* Allocate the matrices. */
if
(
(
a
=
(
double
*
)
malloc
(
sizeof
(
double
)
*
m
*
k
*
32
*
32
)
)
==
NULL
||
if
(
(
a
=
(
double
*
)
malloc
(
sizeof
(
double
)
*
m
*
k
*
32
*
32
)
)
==
NULL
||
...
@@ -209,13 +209,13 @@ void test1 ( int m , int n , int k , int nr_threads ) {
...
@@ -209,13 +209,13 @@ void test1 ( int m , int n , int k , int nr_threads ) {
for
(
i
=
0
;
i
<
m
;
i
++
)
for
(
i
=
0
;
i
<
m
;
i
++
)
for
(
j
=
0
;
j
<
n
;
j
++
)
{
for
(
j
=
0
;
j
<
n
;
j
++
)
{
data
[
0
]
=
i
;
data
[
1
]
=
j
;
data
[
0
]
=
i
;
data
[
1
]
=
j
;
rid
=
sched_addres
(
&
s
,
-
1
);
rid
=
q
sched_addres
(
&
s
,
-
1
);
tid
=
sched_newtask
(
&
s
,
1
,
0
,
0
,
data
,
2
*
sizeof
(
int
)
,
1
);
tid
=
q
sched_newtask
(
&
s
,
1
,
task_flag_none
,
data
,
2
*
sizeof
(
int
)
,
1
);
sched_addlock
(
&
s
,
tid
,
rid
);
q
sched_addlock
(
&
s
,
tid
,
rid
);
}
}
/* Prepare the sched for execution. */
/* Prepare the sched for execution. */
sched_prepare
(
&
s
);
q
sched_prepare
(
&
s
);
/* Parallel loop. */
/* Parallel loop. */
tic_task
=
getticks
();
tic_task
=
getticks
();
...
@@ -229,13 +229,13 @@ void test1 ( int m , int n , int k , int nr_threads ) {
...
@@ -229,13 +229,13 @@ void test1 ( int m , int n , int k , int nr_threads ) {
while
(
1
)
{
while
(
1
)
{
/* Get a task, break if unsucessful. */
/* Get a task, break if unsucessful. */
if
(
(
t
=
sched_gettask
(
&
s
,
qid
)
)
==
NULL
)
if
(
(
t
=
q
sched_gettask
(
&
s
,
qid
)
)
==
NULL
)
break
;
break
;
/* Decode and execute the task. */
/* Decode and execute the task. */
switch
(
t
->
type
)
{
switch
(
t
->
type
)
{
case
1
:
case
1
:
d
=
sched_getdata
(
&
s
,
t
);
d
=
q
sched_getdata
(
&
s
,
t
);
// message( "thread %i working on block [ %i , %i ]." , qid , d[0] , d[1] ); fflush(stdout);
// message( "thread %i working on block [ %i , %i ]." , qid , d[0] , d[1] ); fflush(stdout);
matmul
(
32
,
32
,
k
*
32
,
&
a
[
d
[
0
]
*
32
]
,
m
*
32
,
&
b
[
k
*
32
*
d
[
1
]
*
32
]
,
k
*
32
,
&
c
[
d
[
0
]
*
32
+
m
*
32
*
d
[
1
]
*
32
]
,
m
*
32
);
matmul
(
32
,
32
,
k
*
32
,
&
a
[
d
[
0
]
*
32
]
,
m
*
32
,
&
b
[
k
*
32
*
d
[
1
]
*
32
]
,
k
*
32
,
&
c
[
d
[
0
]
*
32
+
m
*
32
*
d
[
1
]
*
32
]
,
m
*
32
);
break
;
break
;
...
@@ -244,7 +244,7 @@ void test1 ( int m , int n , int k , int nr_threads ) {
...
@@ -244,7 +244,7 @@ void test1 ( int m , int n , int k , int nr_threads ) {
}
}
/* Clean up afterwards. */
/* Clean up afterwards. */
sched_done
(
&
s
,
t
);
q
sched_done
(
&
s
,
t
);
}
/* main loop. */
}
/* main loop. */
...
@@ -270,7 +270,7 @@ void test1 ( int m , int n , int k , int nr_threads ) {
...
@@ -270,7 +270,7 @@ void test1 ( int m , int n , int k , int nr_threads ) {
} */
} */
/* Clean up. */
/* Clean up. */
sched_free
(
&
s
);
q
sched_free
(
&
s
);
free
(
a
);
free
(
a
);
free
(
b
);
free
(
b
);
free
(
c
);
free
(
c
);
...
...
This diff is collapsed.
Click to expand it.
examples/test_bh.c
+
27
−
27
View file @
d0028095
...
@@ -104,7 +104,7 @@ struct cell *cell_get ( ) {
...
@@ -104,7 +104,7 @@ struct cell *cell_get ( ) {
cell_pool
=
cell_pool
->
progeny
[
0
];
cell_pool
=
cell_pool
->
progeny
[
0
];
/* Clean up a few things. */
/* Clean up a few things. */
res
->
res
=
sched_res_none
;
res
->
res
=
q
sched_res_none
;
/* Return the cell. */
/* Return the cell. */
return
res
;
return
res
;
...
@@ -121,7 +121,7 @@ struct cell *cell_get ( ) {
...
@@ -121,7 +121,7 @@ struct cell *cell_get ( ) {
* @param s The #sched to store the resources.
* @param s The #sched to store the resources.
*/
*/
void
cell_split
(
struct
cell
*
c
,
struct
sched
*
s
)
{
void
cell_split
(
struct
cell
*
c
,
struct
q
sched
*
s
)
{
int
i
,
j
,
k
,
count
=
c
->
count
;
int
i
,
j
,
k
,
count
=
c
->
count
;
struct
part
temp
,
*
parts
=
c
->
parts
;
struct
part
temp
,
*
parts
=
c
->
parts
;
...
@@ -130,11 +130,11 @@ void cell_split ( struct cell *c , struct sched *s ) {
...
@@ -130,11 +130,11 @@ void cell_split ( struct cell *c , struct sched *s ) {
double
pivot
[
3
];
double
pivot
[
3
];
/* Add a resource for this cell if it doesn't have one yet. */
/* Add a resource for this cell if it doesn't have one yet. */
if
(
c
->
res
==
sched_res_none
)
if
(
c
->
res
==
q
sched_res_none
)
c
->
res
=
sched_addres
(
s
,
sched_res_none
);
c
->
res
=
q
sched_addres
(
s
,
q
sched_res_none
);
/* Attach a center-of-mass task to the cell. */
/* Attach a center-of-mass task to the cell. */
c
->
com_tid
=
sched_newtask
(
s
,
task_type_com
,
0
,
0
,
&
c
,
sizeof
(
struct
cell
*
)
,
1
);
c
->
com_tid
=
q
sched_newtask
(
s
,
task_type_com
,
task_flag_none
,
&
c
,
sizeof
(
struct
cell
*
)
,
1
);
/* Does this cell need to be split? */
/* Does this cell need to be split? */
if
(
count
>
cell_maxparts
)
{
if
(
count
>
cell_maxparts
)
{
...
@@ -152,7 +152,7 @@ void cell_split ( struct cell *c , struct sched *s ) {
...
@@ -152,7 +152,7 @@ void cell_split ( struct cell *c , struct sched *s ) {
cp
->
h
[
0
]
=
c
->
h
[
0
]
/
2
;
cp
->
h
[
0
]
=
c
->
h
[
0
]
/
2
;
cp
->
h
[
1
]
=
c
->
h
[
1
]
/
2
;
cp
->
h
[
1
]
=
c
->
h
[
1
]
/
2
;
cp
->
h
[
2
]
=
c
->
h
[
2
]
/
2
;
cp
->
h
[
2
]
=
c
->
h
[
2
]
/
2
;
cp
->
res
=
sched_addres
(
s
,
c
->
res
);
cp
->
res
=
q
sched_addres
(
s
,
c
->
res
);
if
(
k
&
4
)
if
(
k
&
4
)
cp
->
loc
[
0
]
+=
cp
->
h
[
0
];
cp
->
loc
[
0
]
+=
cp
->
h
[
0
];
if
(
k
&
2
)
if
(
k
&
2
)
...
@@ -223,7 +223,7 @@ void cell_split ( struct cell *c , struct sched *s ) {
...
@@ -223,7 +223,7 @@ void cell_split ( struct cell *c , struct sched *s ) {
/* Link the COM tasks. */
/* Link the COM tasks. */
for
(
k
=
0
;
k
<
8
;
k
++
)
for
(
k
=
0
;
k
<
8
;
k
++
)
sched_addunlock
(
s
,
c
->
progeny
[
k
]
->
com_tid
,
c
->
com_tid
);
q
sched_addunlock
(
s
,
c
->
progeny
[
k
]
->
com_tid
,
c
->
com_tid
);
}
/* does the cell need to be split? */
}
/* does the cell need to be split? */
...
@@ -483,7 +483,7 @@ void iact_self ( struct cell *c ) {
...
@@ -483,7 +483,7 @@ void iact_self ( struct cell *c ) {
* @param cj The second #cell.
* @param cj The second #cell.
*/
*/
void
create_tasks
(
struct
sched
*
s
,
struct
cell
*
ci
,
struct
cell
*
cj
)
{
void
create_tasks
(
struct
q
sched
*
s
,
struct
cell
*
ci
,
struct
cell
*
cj
)
{
int
j
,
k
,
tid
;
int
j
,
k
,
tid
;
struct
cell
*
data
[
2
];
struct
cell
*
data
[
2
];
...
@@ -519,10 +519,10 @@ void create_tasks ( struct sched *s , struct cell *ci , struct cell *cj ) {
...
@@ -519,10 +519,10 @@ void create_tasks ( struct sched *s , struct cell *ci , struct cell *cj ) {
data
[
0
]
=
ci
;
data
[
1
]
=
NULL
;
data
[
0
]
=
ci
;
data
[
1
]
=
NULL
;
/* Create the task. */
/* Create the task. */
tid
=
sched_newtask
(
s
,
task_type_self
,
0
,
0
,
data
,
sizeof
(
struct
cell
*
)
*
2
,
ci
->
count
*
ci
->
count
/
2
);
tid
=
q
sched_newtask
(
s
,
task_type_self
,
task_flag_none
,
data
,
sizeof
(
struct
cell
*
)
*
2
,
ci
->
count
*
ci
->
count
/
2
);
/* Add the resource. */
/* Add the resource. */
sched_addlock
(
s
,
tid
,
ci
->
res
);
q
sched_addlock
(
s
,
tid
,
ci
->
res
);
}
}
...
@@ -559,15 +559,15 @@ void create_tasks ( struct sched *s , struct cell *ci , struct cell *cj ) {
...
@@ -559,15 +559,15 @@ void create_tasks ( struct sched *s , struct cell *ci , struct cell *cj ) {
/* Interact ci's parts with cj as a cell. */
/* Interact ci's parts with cj as a cell. */
data
[
0
]
=
ci
;
data
[
1
]
=
cj
;
data
[
0
]
=
ci
;
data
[
1
]
=
cj
;
tid
=
sched_newtask
(
s
,
task_type_pair_pc
,
0
,
0
,
data
,
sizeof
(
struct
cell
*
)
*
2
,
ci
->
count
);
tid
=
q
sched_newtask
(
s
,
task_type_pair_pc
,
task_flag_none
,
data
,
sizeof
(
struct
cell
*
)
*
2
,
ci
->
count
);
sched_addlock
(
s
,
tid
,
ci
->
res
);
q
sched_addlock
(
s
,
tid
,
ci
->
res
);
sched_addunlock
(
s
,
cj
->
com_tid
,
tid
);
q
sched_addunlock
(
s
,
cj
->
com_tid
,
tid
);
/* Interact cj's parts with ci as a cell. */
/* Interact cj's parts with ci as a cell. */
data
[
0
]
=
cj
;
data
[
1
]
=
ci
;
data
[
0
]
=
cj
;
data
[
1
]
=
ci
;
tid
=
sched_newtask
(
s
,
task_type_pair_pc
,
0
,
0
,
data
,
sizeof
(
struct
cell
*
)
*
2
,
ci
->
count
);
tid
=
q
sched_newtask
(
s
,
task_type_pair_pc
,
task_flag_none
,
data
,
sizeof
(
struct
cell
*
)
*
2
,
ci
->
count
);
sched_addlock
(
s
,
tid
,
cj
->
res
);
q
sched_addlock
(
s
,
tid
,
cj
->
res
);
sched_addunlock
(
s
,
ci
->
com_tid
,
tid
);
q
sched_addunlock
(
s
,
ci
->
com_tid
,
tid
);
}
}
...
@@ -578,16 +578,16 @@ void create_tasks ( struct sched *s , struct cell *ci , struct cell *cj ) {
...
@@ -578,16 +578,16 @@ void create_tasks ( struct sched *s , struct cell *ci , struct cell *cj ) {
data
[
0
]
=
ci
;
data
[
1
]
=
cj
;
data
[
0
]
=
ci
;
data
[
1
]
=
cj
;
/* Create the task. */
/* Create the task. */
tid
=
sched_newtask
(
s
,
task_type_pair
,
0
,
0
,
data
,
sizeof
(
struct
cell
*
)
*
2
,
ci
->
count
*
cj
->
count
);
tid
=
q
sched_newtask
(
s
,
task_type_pair
,
task_flag_none
,
data
,
sizeof
(
struct
cell
*
)
*
2
,
ci
->
count
*
cj
->
count
);
/* Add the resources. */
/* Add the resources. */
sched_addlock
(
s
,
tid
,
ci
->
res
);
q
sched_addlock
(
s
,
tid
,
ci
->
res
);
sched_addlock
(
s
,
tid
,
cj
->
res
);
q
sched_addlock
(
s
,
tid
,
cj
->
res
);
/* Depend on the COMs in case this task recurses. */
/* Depend on the COMs in case this task recurses. */
if
(
ci
->
split
||
cj
->
split
)
{
if
(
ci
->
split
||
cj
->
split
)
{
sched_addunlock
(
s
,
ci
->
com_tid
,
tid
);
q
sched_addunlock
(
s
,
ci
->
com_tid
,
tid
);
sched_addunlock
(
s
,
cj
->
com_tid
,
tid
);
q
sched_addunlock
(
s
,
cj
->
com_tid
,
tid
);
}
}
}
}
...
@@ -611,10 +611,10 @@ void test_bh ( int N , int nr_threads ) {
...
@@ -611,10 +611,10 @@ void test_bh ( int N , int nr_threads ) {
int
k
;
int
k
;
struct
cell
*
root
;
struct
cell
*
root
;
struct
part
*
parts
;
struct
part
*
parts
;
struct
sched
s
;
struct
q
sched
s
;
/* Initialize the scheduler. */
/* Initialize the scheduler. */
sched_init
(
&
s
,
nr_threads
,
1000
);
q
sched_init
(
&
s
,
nr_threads
,
1000
);
/* Init and fill the particle array. */
/* Init and fill the particle array. */
if
(
(
parts
=
(
struct
part
*
)
malloc
(
sizeof
(
struct
part
)
*
N
)
)
==
NULL
)
if
(
(
parts
=
(
struct
part
*
)
malloc
(
sizeof
(
struct
part
)
*
N
)
)
==
NULL
)
...
@@ -642,7 +642,7 @@ void test_bh ( int N , int nr_threads ) {
...
@@ -642,7 +642,7 @@ void test_bh ( int N , int nr_threads ) {
create_tasks
(
&
s
,
root
,
NULL
);
create_tasks
(
&
s
,
root
,
NULL
);
/* Prepare the scheduler. */
/* Prepare the scheduler. */
sched_prepare
(
&
s
);
q
sched_prepare
(
&
s
);
/* Parallel loop. */
/* Parallel loop. */
#pragma omp parallel
#pragma omp parallel
...
@@ -659,11 +659,11 @@ void test_bh ( int N , int nr_threads ) {
...
@@ -659,11 +659,11 @@ void test_bh ( int N , int nr_threads ) {
while
(
1
)
{
while
(
1
)
{
/* Get a task, break if unsucessful. */
/* Get a task, break if unsucessful. */
if
(
(
t
=
sched_gettask
(
&
s
,
qid
)
)
==
NULL
)
if
(
(
t
=
q
sched_gettask
(
&
s
,
qid
)
)
==
NULL
)
break
;
break
;
/* Get the task's data. */
/* Get the task's data. */
d
=
sched_getdata
(
&
s
,
t
);
d
=
q
sched_getdata
(
&
s
,
t
);
/* Decode and execute the task. */
/* Decode and execute the task. */
switch
(
t
->
type
)
{
switch
(
t
->
type
)
{
...
@@ -684,7 +684,7 @@ void test_bh ( int N , int nr_threads ) {
...
@@ -684,7 +684,7 @@ void test_bh ( int N , int nr_threads ) {
}
}
/* Clean up afterwards. */
/* Clean up afterwards. */
sched_done
(
&
s
,
t
);
q
sched_done
(
&
s
,
t
);
}
/* main loop. */
}
/* main loop. */
...
...
This diff is collapsed.
Click to expand it.
examples/test_qr.c
+
27
−
27
View file @
d0028095
...
@@ -396,7 +396,7 @@ void test_qr ( int m , int n , int nr_threads ) {
...
@@ -396,7 +396,7 @@ void test_qr ( int m , int n , int nr_threads ) {
int
k
,
j
,
i
;
int
k
,
j
,
i
;
double
*
A
,
*
A_orig
,
*
tau
;
double
*
A
,
*
A_orig
,
*
tau
;
struct
sched
s
;
struct
q
sched
s
;
int
*
tid
,
*
rid
,
tid_new
;
int
*
tid
,
*
rid
,
tid_new
;
int
data
[
3
];
int
data
[
3
];
...
@@ -422,7 +422,7 @@ void test_qr ( int m , int n , int nr_threads ) {
...
@@ -422,7 +422,7 @@ void test_qr ( int m , int n , int nr_threads ) {
printf( "];\n" ); */
printf( "];\n" ); */
/* Initialize the scheduler. */
/* Initialize the scheduler. */
sched_init
(
&
s
,
nr_threads
,
m
*
n
);
q
sched_init
(
&
s
,
nr_threads
,
m
*
n
);
/* Allocate and init the task ID and resource ID matrix. */
/* Allocate and init the task ID and resource ID matrix. */
if
(
(
tid
=
(
int
*
)
malloc
(
sizeof
(
int
)
*
m
*
n
)
)
==
NULL
||
if
(
(
tid
=
(
int
*
)
malloc
(
sizeof
(
int
)
*
m
*
n
)
)
==
NULL
||
...
@@ -430,7 +430,7 @@ void test_qr ( int m , int n , int nr_threads ) {
...
@@ -430,7 +430,7 @@ void test_qr ( int m , int n , int nr_threads ) {
error
(
"Failed to allocate tid/rid matrix."
);
error
(
"Failed to allocate tid/rid matrix."
);
for
(
k
=
0
;
k
<
m
*
n
;
k
++
)
{
for
(
k
=
0
;
k
<
m
*
n
;
k
++
)
{
tid
[
k
]
=
-
1
;
tid
[
k
]
=
-
1
;
rid
[
k
]
=
sched_addres
(
&
s
,
-
1
);
rid
[
k
]
=
q
sched_addres
(
&
s
,
-
1
);
}
}
/* Build the tasks. */
/* Build the tasks. */
...
@@ -438,21 +438,21 @@ void test_qr ( int m , int n , int nr_threads ) {
...
@@ -438,21 +438,21 @@ void test_qr ( int m , int n , int nr_threads ) {
/* Add kth corner task. */
/* Add kth corner task. */
data
[
0
]
=
k
;
data
[
1
]
=
k
;
data
[
2
]
=
k
;
data
[
0
]
=
k
;
data
[
1
]
=
k
;
data
[
2
]
=
k
;
tid_new
=
sched_newtask
(
&
s
,
task_DGEQRF
,
0
,
0
,
data
,
sizeof
(
int
)
*
3
,
2
);
tid_new
=
q
sched_newtask
(
&
s
,
task_DGEQRF
,
task_flag_none
,
data
,
sizeof
(
int
)
*
3
,
2
);
sched_addlock
(
&
s
,
tid_new
,
rid
[
k
*
m
+
k
]
);
q
sched_addlock
(
&
s
,
tid_new
,
rid
[
k
*
m
+
k
]
);
if
(
tid
[
k
*
m
+
k
]
!=
-
1
)
if
(
tid
[
k
*
m
+
k
]
!=
-
1
)
sched_addunlock
(
&
s
,
tid
[
k
*
m
+
k
]
,
tid_new
);
q
sched_addunlock
(
&
s
,
tid
[
k
*
m
+
k
]
,
tid_new
);
tid
[
k
*
m
+
k
]
=
tid_new
;
tid
[
k
*
m
+
k
]
=
tid_new
;
/* Add column tasks on kth row. */
/* Add column tasks on kth row. */
for
(
j
=
k
+
1
;
j
<
n
;
j
++
)
{
for
(
j
=
k
+
1
;
j
<
n
;
j
++
)
{
data
[
0
]
=
k
;
data
[
1
]
=
j
;
data
[
2
]
=
k
;
data
[
0
]
=
k
;
data
[
1
]
=
j
;
data
[
2
]
=
k
;
tid_new
=
sched_newtask
(
&
s
,
task_DLARFT
,
0
,
0
,
data
,
sizeof
(
int
)
*
3
,
3
);
tid_new
=
q
sched_newtask
(
&
s
,
task_DLARFT
,
task_flag_none
,
data
,
sizeof
(
int
)
*
3
,
3
);
sched_addlock
(
&
s
,
tid_new
,
rid
[
j
*
m
+
k
]
);
q
sched_addlock
(
&
s
,
tid_new
,
rid
[
j
*
m
+
k
]
);
sched_adduse
(
&
s
,
tid_new
,
rid
[
k
*
m
+
k
]
);
q
sched_adduse
(
&
s
,
tid_new
,
rid
[
k
*
m
+
k
]
);
sched_addunlock
(
&
s
,
tid
[
k
*
m
+
k
]
,
tid_new
);
q
sched_addunlock
(
&
s
,
tid
[
k
*
m
+
k
]
,
tid_new
);
if
(
tid
[
j
*
m
+
k
]
!=
-
1
)
if
(
tid
[
j
*
m
+
k
]
!=
-
1
)
sched_addunlock
(
&
s
,
tid
[
j
*
m
+
k
]
,
tid_new
);
q
sched_addunlock
(
&
s
,
tid
[
j
*
m
+
k
]
,
tid_new
);
tid
[
j
*
m
+
k
]
=
tid_new
;
tid
[
j
*
m
+
k
]
=
tid_new
;
}
}
...
@@ -461,25 +461,25 @@ void test_qr ( int m , int n , int nr_threads ) {
...
@@ -461,25 +461,25 @@ void test_qr ( int m , int n , int nr_threads ) {
/* Add the row taks for the kth column. */
/* Add the row taks for the kth column. */
data
[
0
]
=
i
;
data
[
1
]
=
k
;
data
[
2
]
=
k
;
data
[
0
]
=
i
;
data
[
1
]
=
k
;
data
[
2
]
=
k
;
tid_new
=
sched_newtask
(
&
s
,
task_DTSQRF
,
0
,
0
,
data
,
sizeof
(
int
)
*
3
,
3
);
tid_new
=
q
sched_newtask
(
&
s
,
task_DTSQRF
,
task_flag_none
,
data
,
sizeof
(
int
)
*
3
,
3
);
sched_addlock
(
&
s
,
tid_new
,
rid
[
k
*
m
+
i
]
);
q
sched_addlock
(
&
s
,
tid_new
,
rid
[
k
*
m
+
i
]
);
sched_adduse
(
&
s
,
tid_new
,
rid
[
k
*
m
+
k
]
);
q
sched_adduse
(
&
s
,
tid_new
,
rid
[
k
*
m
+
k
]
);
sched_addunlock
(
&
s
,
tid
[
k
*
m
+
(
i
-
1
)
]
,
tid_new
);
q
sched_addunlock
(
&
s
,
tid
[
k
*
m
+
(
i
-
1
)
]
,
tid_new
);
if
(
tid
[
k
*
m
+
i
]
!=
-
1
)
if
(
tid
[
k
*
m
+
i
]
!=
-
1
)
sched_addunlock
(
&
s
,
tid
[
k
*
m
+
i
]
,
tid_new
);
q
sched_addunlock
(
&
s
,
tid
[
k
*
m
+
i
]
,
tid_new
);
tid
[
k
*
m
+
i
]
=
tid_new
;
tid
[
k
*
m
+
i
]
=
tid_new
;
/* Add the inner tasks. */
/* Add the inner tasks. */
for
(
j
=
k
+
1
;
j
<
n
;
j
++
)
{
for
(
j
=
k
+
1
;
j
<
n
;
j
++
)
{
data
[
0
]
=
i
;
data
[
1
]
=
j
;
data
[
2
]
=
k
;
data
[
0
]
=
i
;
data
[
1
]
=
j
;
data
[
2
]
=
k
;
tid_new
=
sched_newtask
(
&
s
,
task_DSSRFT
,
0
,
0
,
data
,
sizeof
(
int
)
*
3
,
5
);
tid_new
=
q
sched_newtask
(
&
s
,
task_DSSRFT
,
task_flag_none
,
data
,
sizeof
(
int
)
*
3
,
5
);
sched_addlock
(
&
s
,
tid_new
,
rid
[
j
*
m
+
i
]
);
q
sched_addlock
(
&
s
,
tid_new
,
rid
[
j
*
m
+
i
]
);
sched_adduse
(
&
s
,
tid_new
,
rid
[
k
*
m
+
i
]
);
q
sched_adduse
(
&
s
,
tid_new
,
rid
[
k
*
m
+
i
]
);
sched_adduse
(
&
s
,
tid_new
,
rid
[
j
*
m
+
k
]
);
q
sched_adduse
(
&
s
,
tid_new
,
rid
[
j
*
m
+
k
]
);
sched_addunlock
(
&
s
,
tid
[
k
*
m
+
i
]
,
tid_new
);
q
sched_addunlock
(
&
s
,
tid
[
k
*
m
+
i
]
,
tid_new
);
sched_addunlock
(
&
s
,
tid
[
j
*
m
+
k
]
,
tid_new
);
q
sched_addunlock
(
&
s
,
tid
[
j
*
m
+
k
]
,
tid_new
);
if
(
tid
[
j
*
m
+
i
]
!=
-
1
)
if
(
tid
[
j
*
m
+
i
]
!=
-
1
)
sched_addunlock
(
&
s
,
tid
[
j
*
m
+
i
]
,
tid_new
);
q
sched_addunlock
(
&
s
,
tid
[
j
*
m
+
i
]
,
tid_new
);
tid
[
j
*
m
+
i
]
=
tid_new
;
tid
[
j
*
m
+
i
]
=
tid_new
;
}
}
...
@@ -488,7 +488,7 @@ void test_qr ( int m , int n , int nr_threads ) {
...
@@ -488,7 +488,7 @@ void test_qr ( int m , int n , int nr_threads ) {
}
/* build the tasks. */
}
/* build the tasks. */
/* Prepare the scheduler. */
/* Prepare the scheduler. */
sched_prepare
(
&
s
);
q
sched_prepare
(
&
s
);
/* Parallel loop. */
/* Parallel loop. */
#pragma omp parallel
#pragma omp parallel
...
@@ -505,11 +505,11 @@ void test_qr ( int m , int n , int nr_threads ) {
...
@@ -505,11 +505,11 @@ void test_qr ( int m , int n , int nr_threads ) {
while
(
1
)
{
while
(
1
)
{
/* Get a task, break if unsucessful. */
/* Get a task, break if unsucessful. */
if
(
(
t
=
sched_gettask
(
&
s
,
qid
)
)
==
NULL
)
if
(
(
t
=
q
sched_gettask
(
&
s
,
qid
)
)
==
NULL
)
break
;
break
;
/* Get the task's data. */
/* Get the task's data. */
d
=
sched_getdata
(
&
s
,
t
);
d
=
q
sched_getdata
(
&
s
,
t
);
i
=
d
[
0
];
j
=
d
[
1
];
k
=
d
[
2
];
i
=
d
[
0
];
j
=
d
[
1
];
k
=
d
[
2
];
/* Decode and execute the task. */
/* Decode and execute the task. */
...
@@ -531,7 +531,7 @@ void test_qr ( int m , int n , int nr_threads ) {
...
@@ -531,7 +531,7 @@ void test_qr ( int m , int n , int nr_threads ) {
}
}
/* Clean up afterwards. */
/* Clean up afterwards. */
sched_done
(
&
s
,
t
);
q
sched_done
(
&
s
,
t
);
}
/* main loop. */
}
/* main loop. */
...
...
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