@@ -229,7 +229,7 @@ class Executor {
229
229
std::atomic<size_t > _num_thieves {0 };
230
230
std::atomic<bool > _done {0 };
231
231
232
- Notifier _notifier;
232
+ // Notifier _notifier;
233
233
234
234
std::unique_ptr<ExecutorObserverInterface> _observer;
235
235
@@ -261,8 +261,8 @@ class Executor {
261
261
// Constructor
262
262
inline Executor::Executor (unsigned N) :
263
263
_workers {N},
264
- _waiters {N},
265
- _notifier {_waiters} {
264
+ _waiters {N} {
265
+ // _notifier {_waiters} {
266
266
_spawn (N);
267
267
}
268
268
@@ -274,7 +274,7 @@ inline Executor::~Executor() {
274
274
275
275
// shut down the scheduler
276
276
_done = true ;
277
- _notifier.notify (true );
277
+ // _notifier.notify(true);
278
278
279
279
for (auto & t : _threads){
280
280
t.join ();
@@ -354,6 +354,7 @@ inline unsigned Executor::_find_victim(unsigned thief) {
354
354
return _workers.size ();
355
355
}
356
356
357
+
357
358
// Function: _explore_task
358
359
inline void Executor::_explore_task (unsigned thief, std::optional<Node*>& t) {
359
360
@@ -363,59 +364,32 @@ inline void Executor::_explore_task(unsigned thief, std::optional<Node*>& t) {
363
364
const unsigned l = 0 ;
364
365
const unsigned r = _workers.size () - 1 ;
365
366
366
- const size_t F = (_workers.size () + 1 ) << 1 ;
367
- const size_t Y = 100 ;
368
-
369
- size_t f = 0 ;
370
- size_t y = 0 ;
371
-
372
367
// explore
373
368
while (!_done) {
374
369
370
+ std::this_thread::yield ();
371
+
375
372
unsigned vtm = std::uniform_int_distribution<unsigned >{l, r}(
376
373
_workers[thief].rdgen
377
374
);
378
375
379
376
t = (vtm == thief) ? _queue.steal () : _workers[vtm].queue .steal ();
380
377
381
378
if (t) {
382
- break ;
383
- }
384
-
385
- if (f++ > F) {
386
- if (std::this_thread::yield (); y++ > Y) {
387
- break ;
388
- }
389
- }
390
-
391
- /* if(auto vtm = _find_victim(thief); vtm != _workers.size()) {
392
- t = (vtm == thief) ? _queue.steal() : _workers[vtm].queue.steal();
393
- // successful thief
394
- if(t) {
395
- break;
396
- }
379
+ return ;
397
380
}
398
- else {
399
- if(f++ > F) {
400
- if(std::this_thread::yield(); y++ > Y) {
401
- break;
402
- }
403
- }
404
- }*/
405
381
}
406
382
407
383
}
408
384
385
+
409
386
// Procedure: _exploit_task
410
387
inline void Executor::_exploit_task (unsigned i, std::optional<Node*>& t) {
411
388
412
389
assert (!_workers[i].cache );
413
390
414
391
if (t) {
415
392
auto & worker = _workers[i];
416
- if (_num_actives.fetch_add (1 ) == 0 && _num_thieves == 0 ) {
417
- _notifier.notify (false );
418
- }
419
393
do {
420
394
_invoke (i, *t);
421
395
@@ -428,64 +402,23 @@ inline void Executor::_exploit_task(unsigned i, std::optional<Node*>& t) {
428
402
}
429
403
430
404
} while (t);
431
-
432
- --_num_actives;
433
405
}
434
406
}
435
407
408
+
436
409
// Function: _wait_for_task
437
410
inline bool Executor::_wait_for_task (unsigned me, std::optional<Node*>& t) {
438
411
439
- wait_for_task:
440
-
441
412
assert (!t);
442
413
443
- ++_num_thieves;
444
-
445
- explore_task:
446
-
447
414
if (_explore_task (me, t); t) {
448
- if (auto N = _num_thieves.fetch_sub (1 ); N == 1 ) {
449
- _notifier.notify (false );
450
- }
451
415
return true ;
452
416
}
453
-
454
- _notifier.prepare_wait (&_waiters[me]);
455
-
456
- // if(auto vtm = _find_victim(me); vtm != _workers.size()) {
457
- if (!_queue.empty ()) {
458
-
459
- _notifier.cancel_wait (&_waiters[me]);
460
- // t = (vtm == me) ? _queue.steal() : _workers[vtm].queue.steal();
461
-
462
- if (t = _queue.steal (); t) {
463
- if (auto N = _num_thieves.fetch_sub (1 ); N == 1 ) {
464
- _notifier.notify (false );
465
- }
466
- return true ;
467
- }
468
- else {
469
- goto explore_task;
470
- }
471
- }
472
-
473
- if (_done) {
474
- _notifier.cancel_wait (&_waiters[me]);
475
- _notifier.notify (true );
476
- --_num_thieves;
417
+ else {
477
418
return false ;
478
419
}
479
420
480
- if (_num_thieves.fetch_sub (1 ) == 1 && _num_actives) {
481
- _notifier.cancel_wait (&_waiters[me]);
482
- goto wait_for_task;
483
- }
484
-
485
- // Now I really need to relinguish my self to others
486
- _notifier.commit_wait (&_waiters[me]);
487
-
488
- return true ;
421
+ assert (false );
489
422
}
490
423
491
424
// Function: make_observer
@@ -563,7 +496,7 @@ inline void Executor::_schedule(Node* node, bool bypass) {
563
496
_queue.push (node);
564
497
}
565
498
566
- _notifier.notify (false );
499
+ // _notifier.notify(false);
567
500
}
568
501
569
502
// Procedure: _schedule
@@ -603,7 +536,7 @@ inline void Executor::_schedule(PassiveVector<Node*>& nodes) {
603
536
}
604
537
}
605
538
606
- _notifier.notify (false );
539
+ // _notifier.notify(false);
607
540
}
608
541
609
542
// Procedure: _init_module_node
0 commit comments