view TaskManager/Gpu/GpuThreads.h @ 1445:ef6933a92fff draft

debug GpuTaskManagerImpl
author Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
date Mon, 23 Apr 2012 22:01:08 +0900
parents dff9b3f388e2
children e8ff87511f46
line wrap: on
line source

#ifndef INCLUDED_GPU_THREADS
#define INCLUDED_GPU_THREADS

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

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

// Singleton Pattern
struct gpu_arg {
    GpuScheduler *scheduler;
    int useRefDma;
};

class GpuThreads : public Threads {
public:
    static GpuThreads* getInstance() {
        static GpuThreads* singleton;
        return singleton;
    }
    ~GpuThreads();

    void init();
    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);

public:
    cl_platform_id platform_id;
    cl_device_id device_id;
    cl_uint ret_num_platforms;
    cl_uint ret_num_devices;
    cl_context context;
    cl_command_queue command_queue;

private:
    GpuThreads();

    gpu_arg *args;
    pthread_t *threads;
    int use_refdma;
};

#endif