Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dgl
Commits
56962858
Unverified
Commit
56962858
authored
Nov 15, 2022
by
Quan (Andy) Gan
Committed by
GitHub
Nov 15, 2022
Browse files
[Performance] Make IdHashMap parallel (#4881)
* make IdHashMap parallel * fix * Update array_utils.h
parent
00c27cb2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
3 deletions
+8
-3
src/array/cpu/array_utils.h
src/array/cpu/array_utils.h
+8
-3
No files found.
src/array/cpu/array_utils.h
View file @
56962858
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
#define DGL_ARRAY_CPU_ARRAY_UTILS_H_
#define DGL_ARRAY_CPU_ARRAY_UTILS_H_
#include <dgl/aten/types.h>
#include <dgl/aten/types.h>
#include <dgl/runtime/parallel_for.h>
#include <parallel_hashmap/phmap.h>
#include <parallel_hashmap/phmap.h>
#include <unordered_map>
#include <unordered_map>
...
@@ -81,9 +82,13 @@ class IdHashMap {
...
@@ -81,9 +82,13 @@ class IdHashMap {
const
IdType
*
ids_data
=
static_cast
<
IdType
*>
(
ids
->
data
);
const
IdType
*
ids_data
=
static_cast
<
IdType
*>
(
ids
->
data
);
const
int64_t
len
=
ids
->
shape
[
0
];
const
int64_t
len
=
ids
->
shape
[
0
];
IdArray
values
=
NewIdArray
(
len
,
ids
->
ctx
,
ids
->
dtype
.
bits
);
IdArray
values
=
NewIdArray
(
len
,
ids
->
ctx
,
ids
->
dtype
.
bits
);
IdType
*
values_data
=
static_cast
<
IdType
*>
(
values
->
data
);
IdType
*
values_data
=
values
.
Ptr
<
IdType
>
();
for
(
int64_t
i
=
0
;
i
<
len
;
++
i
)
runtime
::
parallel_for
(
0
,
len
,
1000
,
[
=
]
(
size_t
begin
,
size_t
end
)
{
for
(
size_t
i
=
begin
;
i
<
end
;
++
i
)
{
values_data
[
i
]
=
Map
(
ids_data
[
i
],
default_val
);
values_data
[
i
]
=
Map
(
ids_data
[
i
],
default_val
);
}
});
return
values
;
return
values
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment