void AplusUpdateQueue::process(void) { unsigned int i=0, len=_queue.length(); AplusUpdate *upd; // // _queue may change while this loop is running; additional elements may get pushed // onto the queue if updating involves any dependencies. Therefore, we provide an // external "do-while" loop, on top of the simple iterating "for" loop, to process those // additional elements (if any) // do { for (; i<len; ++i) { upd = (AplusUpdate *)_queue(i); upd->send(); // send the update delete upd; } len = _queue.length(); // get the new length to see if any elements have been added } while (i<len); // i is now equal to the old length; compare it with the new one _queue.removeAll(); // clean up the queue }
cl::Event enqueue_transform(std::vector<cl::Event> &events_wait) { cl_event tmp; ASSERT_THROW_CL(clfftEnqueueTransform(_plan_handle, _direction, 1, &_queue(), events_wait.size(), events_wait.empty() ? NULL : (cl_event*)&events_wait.front(), &tmp, &_in.get_device_buffer()(), &_out.get_device_buffer()(), NULL)); return cl::Event(tmp); }
AplusUpdateQueue::~AplusUpdateQueue(void) { unsigned int len=_queue.length(); AplusUpdate *upd; for (int i=0; i<len; ++i) { upd = (AplusUpdate *)_queue(i); delete upd; } }
uint64_t coroutine_sleep(uint64_t msecs) { struct coroutine *co = _running_coroutine(); co->status = STATUS_ASYNC; if (msecs == 0) { co->status = STATUS_QUEUE; _queue(co->sched, co); } // FIXME insert co to sleeping queue, wait for wakeup. return (uint64_t)(uintptr_t)_yield(co); }
void resize(::size_t n) { if (n == _in.size() && n == _out.size()) return; _in.resize(n); _out.resize(n); ::size_t clLengths[1] = { n }; ASSERT_THROW_CL(clfftCreateDefaultPlan(&_plan_handle, _queue.getInfo<CL_QUEUE_CONTEXT>()(), CLFFT_1D, clLengths)); ASSERT_THROW_CL(clfftSetPlanPrecision ( _plan_handle, CLFFT_SINGLE)); ASSERT_THROW_CL(clfftSetPlanScale ( _plan_handle, _direction, 1.0f)); ASSERT_THROW_CL(clfftSetLayout ( _plan_handle, CLFFT_COMPLEX_INTERLEAVED, CLFFT_COMPLEX_INTERLEAVED)); ASSERT_THROW_CL(clfftSetResultLocation( _plan_handle, CLFFT_OUTOFPLACE)); ASSERT_THROW_CL(clfftBakePlan ( _plan_handle, 1, &_queue(), NULL, NULL)); }
CLCommandQueue CLEvent::queue() const { return CLCommandQueue( _queue() ); }