Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
SWIFTsim
Commits
d47326d2
Commit
d47326d2
authored
9 years ago
by
Pedro Gonnet
Browse files
Options
Downloads
Patches
Plain Diff
add task_overlap function to compute the jaccard similarity of the resources of two tasks.
parent
0b33a4ca
No related branches found
No related tags found
2 merge requests
!136
Master
,
!75
Overlapping tasks
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/task.c
+51
-4
51 additions, 4 deletions
src/task.c
with
51 additions
and
4 deletions
src/task.c
+
51
−
4
View file @
d47326d2
...
...
@@ -43,10 +43,57 @@
/* Task type names. */
const
char
*
taskID_names
[
task_type_count
]
=
{
"none"
,
"sort"
,
"self"
,
"pair"
,
"sub"
,
"ghost"
,
"kick1"
,
"kick2"
,
"send"
,
"recv"
,
"grav_pp"
,
"grav_mm"
,
"grav_up"
,
"grav_down"
,
"psort"
,
"split_cell"
,
"rewait"
};
"none"
,
"sort"
,
"self"
,
"pair"
,
"sub"
,
"ghost"
,
"kick1"
,
"kick2"
,
"send"
,
"recv"
,
"grav_pp"
,
"grav_mm"
,
"grav_up"
,
"grav_down"
,
"psort"
,
"split_cell"
,
"rewait"
};
/**
* @brief Computes the overlap between the parts array of two given cells.
*/
size_t
task_cell_overlap
(
const
struct
cell
*
ci
,
const
struct
cell
*
cj
)
{
if
(
ci
==
NULL
||
cj
==
NULL
)
return
0
;
if
(
ci
->
parts
<=
cj
->
parts
&&
ci
->
parts
+
ci
->
count
>=
cj
->
parts
+
cj
->
count
)
{
return
cj
->
count
;
}
else
if
(
cj
->
parts
<=
ci
->
parts
&&
cj
->
parts
+
cj
->
count
>=
ci
->
parts
+
ci
->
count
)
{
return
ci
->
count
;
}
return
0
;
}
/**
* @brief Compute the Jaccard similarity of the data used by two
* different tasks.
*
* @param ta The first #task.
* @param tb The second #task.
*/
float
task_overlap
(
const
struct
task
*
ta
,
const
struct
task
*
tb
)
{
/* First check if any of the two tasks are of a type that don't
use cells. */
if
(
ta
->
type
==
task_type_none
||
ta
->
type
==
task_type_psort
||
ta
->
type
==
task_type_split_cell
||
ta
->
type
==
task_type_rewait
||
tb
->
type
==
task_type_none
||
tb
->
type
==
task_type_psort
||
tb
->
type
==
task_type_split_cell
||
tb
->
type
==
task_type_rewait
)
return
0
.
0
f
;
/* Compute the union of the cell data. */
size_t
size_union
=
0
;
if
(
ta
->
ci
!=
NULL
)
size_union
+=
ta
->
ci
->
count
;
if
(
ta
->
cj
!=
NULL
)
size_union
+=
ta
->
cj
->
count
;
if
(
tb
->
ci
!=
NULL
)
size_union
+=
tb
->
ci
->
count
;
if
(
tb
->
cj
!=
NULL
)
size_union
+=
tb
->
cj
->
count
;
/* Compute the intersection of the cell data. */
const
size_t
size_intersect
=
task_cell_overlap
(
ta
->
ci
,
tb
->
ci
)
+
task_cell_overlap
(
ta
->
ci
,
tb
->
cj
)
+
task_cell_overlap
(
ta
->
cj
,
tb
->
ci
)
+
task_cell_overlap
(
ta
->
cj
,
tb
->
cj
);
return
((
float
)
size_intersect
)
/
(
size_union
-
size_intersect
);
}
/**
* @brief Unlock the cell held by this task.
...
...
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