Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython_plus_experiments
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Julien Jerphanion
cython_plus_experiments
Commits
27426854
Commit
27426854
authored
Jun 16, 2021
by
Julien Jerphanion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add queue to workers in round robin
parent
88933876
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
4 deletions
+9
-4
kdtree/runtime/runtime.pxd
kdtree/runtime/runtime.pxd
+9
-4
No files found.
kdtree/runtime/runtime.pxd
View file @
27426854
...
...
@@ -104,12 +104,16 @@ cdef cypclass Scheduler:
pthread_barrier_t
barrier
sem_t
num_free_queues
atomic
[
int
]
num_pending_queues
int
next_worker
int
num_workers
sem_t
done
volatile
bint
is_done
lock
Scheduler
__new__
(
alloc
,
int
num_workers
=
0
):
self
=
<
lock
Scheduler
>
consume
alloc
()
if
num_workers
==
0
:
num_workers
=
sysconf
(
_SC_NPROCESSORS_ONLN
)
self
.
num_workers
=
num_workers
self
.
next_worker
=
0
sem_init
(
&
self
.
num_free_queues
,
0
,
0
)
sem_init
(
&
self
.
done
,
0
,
0
)
self
.
num_pending_queues
.
store
(
0
)
...
...
@@ -137,11 +141,12 @@ cdef cypclass Scheduler:
sem_destroy
(
&
self
.
done
)
void
post_queue
(
self
,
lock
SequentialMailBox
queue
):
# Add a queue to the first worker.
main_worker
=
self
.
workers
[
0
]
with
wlocked
main_worker
:
# Add a queue to workers in round robin
worker
=
self
.
workers
[
<
int
>
self
.
next_worker
]
self
.
next_worker
=
(
self
.
next_worker
+
1
)
%
self
.
num_workers
with
wlocked
worker
:
queue
.
has_worker
=
True
main_
worker
.
queues
.
push_back
(
queue
)
worker
.
queues
.
push_back
(
queue
)
# Increment the number of non-completed queues.
self
.
num_pending_queues
.
fetch_add
(
1
)
# Signal that a queue is available.
...
...
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