view src/parallel_execution/worker.c @ 164:b0c6e0392b00

Add comment to stack.agda
author atton
date Thu, 17 Nov 2016 18:28:13 +0000
parents 63ab65b28466
children ea7b11f3e717
line wrap: on
line source

#include <libkern/OSAtomic.h>

#include "context.h"
#include "origin_cs.h"

__code getQueue(struct Context* context, struct Queue* queue, struct Node* node) {
    if (queue->first == 0)
        return;

    struct Element* first = queue->first;
    if (__sync_bool_compare_and_swap(&queue->first, first, first->next)) {
        queue->count--;

        context->next = GetQueue;
        node->key = ((struct Task *)(first->data))->key;

        struct Traverse *t = &context->data[D_Traverse]->Traverse;
        t->next = ((struct Task *)(first->data))->code;
        goto meta(context, C_get);
    } else {
        goto meta(context, GetQueue);
    }
}

__code getQueue_stub(struct Context* context) {
    goto getQueue(context, &context->data[D_ActiveQueue]->queue, &context->data[D_Node]->node);
}

#ifdef USE_CUDA
__code twiceGpu(struct Context* context) {
    cuMemcpyHtoDAsync(context,context,context,context->stream);
    cuLaunchkanel();
    cuMemcpyDtoHAsync();
}
#endif