[host] improved latency of multimemcpy with hybrid locking and preempt

This commit is contained in:
Geoffrey McRae
2017-12-29 07:00:27 +11:00
parent f6f4c8070a
commit 2f2813037b
2 changed files with 31 additions and 10 deletions

View File

@@ -29,19 +29,34 @@ public:
MultiMemcpy();
~MultiMemcpy();
// preempt the copy and wake up the threads early
inline void Wake()
{
if (m_awake)
return;
for (int i = 0; i < MULTIMEMCPY_THREADS; ++i)
ReleaseSemaphore(m_workers[i].start, 1, NULL);
m_awake = true;
}
void Copy(void * dst, void * src, size_t size);
private:
struct Worker
{
unsigned int id;
volatile char *running;
HANDLE start;
HANDLE stop;
HANDLE thread;
void * dst;
void * src;
size_t size;
};
HANDLE m_semaphores[MULTIMEMCPY_THREADS];
bool m_awake;
volatile char m_running;
struct Worker m_workers[MULTIMEMCPY_THREADS];
static DWORD WINAPI WorkerFunction(LPVOID param);
};