Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libkomp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Service Desk
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
openmp
libkomp
Commits
ea51ac6c
Commit
ea51ac6c
authored
6 years ago
by
Philippe Virouleau
Browse files
Options
Downloads
Patches
Plain Diff
Use prime numbers for hash sizes
parent
4e120d78
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
runtime/src/kmp.h
+1
-2
1 addition, 2 deletions
runtime/src/kmp.h
runtime/src/kmp_taskdeps.cpp
+18
-5
18 additions, 5 deletions
runtime/src/kmp_taskdeps.cpp
with
19 additions
and
7 deletions
runtime/src/kmp.h
+
1
−
2
View file @
ea51ac6c
...
@@ -2248,10 +2248,9 @@ struct kmp_dephash_entry {
...
@@ -2248,10 +2248,9 @@ struct kmp_dephash_entry {
typedef
struct
kmp_dephash
{
typedef
struct
kmp_dephash
{
kmp_dephash_entry_t
**
buckets
;
kmp_dephash_entry_t
**
buckets
;
size_t
size
;
size_t
size
;
size_t
generation
;
kmp_uint32
nelements
;
kmp_uint32
nelements
;
#ifdef KMP_DEBUG
kmp_uint32
nconflicts
;
kmp_uint32
nconflicts
;
#endif
}
kmp_dephash_t
;
}
kmp_dephash_t
;
#if OMP_50_ENABLED
#if OMP_50_ENABLED
...
...
This diff is collapsed.
Click to expand it.
runtime/src/kmp_taskdeps.cpp
+
18
−
5
View file @
ea51ac6c
...
@@ -56,6 +56,8 @@ static inline kmp_depnode_t *__kmp_node_ref(kmp_depnode_t *node) {
...
@@ -56,6 +56,8 @@ static inline kmp_depnode_t *__kmp_node_ref(kmp_depnode_t *node) {
enum
{
KMP_DEPHASH_OTHER_SIZE
=
97
,
KMP_DEPHASH_MASTER_SIZE
=
997
};
enum
{
KMP_DEPHASH_OTHER_SIZE
=
97
,
KMP_DEPHASH_MASTER_SIZE
=
997
};
size_t
sizes
[]
=
{
997
,
2003
,
4001
,
8191
,
16001
,
32003
,
64007
,
131071
,
270029
};
static
inline
kmp_int32
__kmp_dephash_hash
(
kmp_intptr_t
addr
,
size_t
hsize
)
{
static
inline
kmp_int32
__kmp_dephash_hash
(
kmp_intptr_t
addr
,
size_t
hsize
)
{
// TODO alternate to try: set = (((Addr64)(addrUsefulBits * 9.618)) %
// TODO alternate to try: set = (((Addr64)(addrUsefulBits * 9.618)) %
// m_num_sets );
// m_num_sets );
...
@@ -66,7 +68,14 @@ static kmp_dephash_t *__kmp_dephash_extend(kmp_info_t *thread,
...
@@ -66,7 +68,14 @@ static kmp_dephash_t *__kmp_dephash_extend(kmp_info_t *thread,
kmp_dephash_t
*
current_dephash
)
{
kmp_dephash_t
*
current_dephash
)
{
kmp_dephash_t
*
h
;
kmp_dephash_t
*
h
;
size_t
gen
=
current_dephash
->
generation
+
1
;
#if 1
if
(
gen
>=
9
)
return
current_dephash
;
size_t
new_size
=
sizes
[
gen
];
#else
size_t
new_size
=
current_dephash
->
size
*
2
;
size_t
new_size
=
current_dephash
->
size
*
2
;
#endif
kmp_int32
size_to_allocate
=
kmp_int32
size_to_allocate
=
new_size
*
sizeof
(
kmp_dephash_entry_t
*
)
+
sizeof
(
kmp_dephash_t
);
new_size
*
sizeof
(
kmp_dephash_entry_t
*
)
+
sizeof
(
kmp_dephash_t
);
...
@@ -80,15 +89,21 @@ static kmp_dephash_t *__kmp_dephash_extend(kmp_info_t *thread,
...
@@ -80,15 +89,21 @@ static kmp_dephash_t *__kmp_dephash_extend(kmp_info_t *thread,
h
->
size
=
new_size
;
h
->
size
=
new_size
;
h
->
nelements
=
current_dephash
->
nelements
;
h
->
nelements
=
current_dephash
->
nelements
;
h
->
buckets
=
(
kmp_dephash_entry
**
)(
h
+
1
);
h
->
buckets
=
(
kmp_dephash_entry
**
)(
h
+
1
);
h
->
generation
=
gen
;
// insert existing elements in the new table
// insert existing elements in the new table
for
(
size_t
i
=
0
;
i
<
current_dephash
->
size
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
current_dephash
->
size
;
i
++
)
{
kmp_dephash_entry_t
*
next
;
kmp_dephash_entry_t
*
next
;
int
nelems
=
0
;
for
(
kmp_dephash_entry_t
*
entry
=
current_dephash
->
buckets
[
i
];
entry
;
entry
=
next
)
{
for
(
kmp_dephash_entry_t
*
entry
=
current_dephash
->
buckets
[
i
];
entry
;
entry
=
next
)
{
next
=
entry
->
next_in_bucket
;
next
=
entry
->
next_in_bucket
;
// Compute the new hash using the new size, and insert the entry in
// Compute the new hash using the new size, and insert the entry in
// the new bucket.
// the new bucket.
kmp_int32
new_bucket
=
__kmp_dephash_hash
(
entry
->
addr
,
h
->
size
);
kmp_int32
new_bucket
=
__kmp_dephash_hash
(
entry
->
addr
,
h
->
size
);
nelems
++
;
if
(
entry
->
next_in_bucket
)
{
h
->
nconflicts
++
;
}
entry
->
next_in_bucket
=
h
->
buckets
[
new_bucket
];
entry
->
next_in_bucket
=
h
->
buckets
[
new_bucket
];
h
->
buckets
[
new_bucket
]
=
entry
;
h
->
buckets
[
new_bucket
]
=
entry
;
}
}
...
@@ -125,10 +140,9 @@ static kmp_dephash_t *__kmp_dephash_create(kmp_info_t *thread,
...
@@ -125,10 +140,9 @@ static kmp_dephash_t *__kmp_dephash_create(kmp_info_t *thread,
#endif
#endif
h
->
size
=
h_size
;
h
->
size
=
h_size
;
h
->
generation
=
0
;
h
->
nelements
=
0
;
h
->
nelements
=
0
;
#ifdef KMP_DEBUG
h
->
nconflicts
=
0
;
h
->
nconflicts
=
0
;
#endif
h
->
buckets
=
(
kmp_dephash_entry
**
)(
h
+
1
);
h
->
buckets
=
(
kmp_dephash_entry
**
)(
h
+
1
);
for
(
size_t
i
=
0
;
i
<
h_size
;
i
++
)
for
(
size_t
i
=
0
;
i
<
h_size
;
i
++
)
...
@@ -144,7 +158,8 @@ static kmp_dephash_entry *
...
@@ -144,7 +158,8 @@ static kmp_dephash_entry *
__kmp_dephash_find
(
kmp_info_t
*
thread
,
kmp_dephash_t
**
hash
,
kmp_intptr_t
addr
)
{
__kmp_dephash_find
(
kmp_info_t
*
thread
,
kmp_dephash_t
**
hash
,
kmp_intptr_t
addr
)
{
kmp_dephash_t
*
h
=
*
hash
;
kmp_dephash_t
*
h
=
*
hash
;
if
(
h
->
nelements
!=
0
if
(
h
->
nelements
!=
0
&&
h
->
nelements
>=
h
->
size
)
{
&&
h
->
nconflicts
/
h
->
size
>=
1
)
{
//&& h->nelements >= h->size) {
//fprintf(stderr, "Resizing hashtable\n");
//fprintf(stderr, "Resizing hashtable\n");
*
hash
=
__kmp_dephash_extend
(
thread
,
h
);
*
hash
=
__kmp_dephash_extend
(
thread
,
h
);
h
=
*
hash
;
h
=
*
hash
;
...
@@ -174,10 +189,8 @@ __kmp_dephash_find(kmp_info_t *thread, kmp_dephash_t **hash, kmp_intptr_t addr)
...
@@ -174,10 +189,8 @@ __kmp_dephash_find(kmp_info_t *thread, kmp_dephash_t **hash, kmp_intptr_t addr)
entry
->
next_in_bucket
=
h
->
buckets
[
bucket
];
entry
->
next_in_bucket
=
h
->
buckets
[
bucket
];
h
->
buckets
[
bucket
]
=
entry
;
h
->
buckets
[
bucket
]
=
entry
;
h
->
nelements
++
;
h
->
nelements
++
;
#ifdef KMP_DEBUG
if
(
entry
->
next_in_bucket
)
if
(
entry
->
next_in_bucket
)
h
->
nconflicts
++
;
h
->
nconflicts
++
;
#endif
}
}
return
entry
;
return
entry
;
}
}
...
...
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