view src/parallel_execution/worker.c @ 143:34a7a21edc36

recude stack get using traverse field
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Wed, 09 Nov 2016 22:33:16 +0900
parents a4507906938c
children d529c024e5a5
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[Traverse]->traverse;
        t->next = ((struct Task *)(first->data))->code;
        goto meta(context, Get);
    } else {
        goto meta(context, GetQueue);
    }
}

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

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