view TaskManager/Gpu/GpuThreads.h @ 1553:21ddbc06dcde draft

fix GpuScheduler
author Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
date Sun, 17 Feb 2013 19:42:36 +0900
parents 2983e9e93d24
children e8c9a7099bcc
line wrap: on
line source

#ifndef INCLUDED_GPU_THREADS
#define INCLUDED_GPU_THREADS

#include <pthread.h>
#include "Threads.h"
#include "GpuScheduler.h"
#include "Sem.h"

#ifdef __APPLE__
#include <OpenCL/opencl.h>
#else
#include <CL/cl.h>
#endif

class GpuScheduler;

typedef struct gpu_arg {
    int cpuid;
    // should be syncrhonized
    GpuScheduler *scheduler;
    TaskManagerImpl *manager;
    SemPtr wait;
	int useRefDma;
} gpu_thread_arg_t;

class GpuThreads : public Threads {
 public:
    /*
      static GpuThreads* getInstance() {
      static GpuThreads singleton;
      return &singleton;
      }*/
    GpuThreads(int useRefDma);
    ~GpuThreads();
    
    void init();
    static void *gpu_thread_run(void *args);

    int get_mail(int speid, int count, memaddr *ret);
    int has_mail(int speid, int count, memaddr *ret);
    void send_mail(int speid, int num, memaddr *data);
    void add_output_tasklist(int command, memaddr buff, int alloc_size);
    void set_wait(SemPtr);

  private:
    gpu_thread_arg_t *args;
    pthread_t *threads;
    int use_refdma;
};

#endif