view TaskManager/Cuda/CudaThreads.h @ 2047:de89da997e07 draft

add FileMapReduce
author Nozomi
date Wed, 27 Jan 2016 19:09:33 +0900
parents cd5bbd8ec5d6
children
line wrap: on
line source

#ifndef INCLUDED_CUDA_THREADS
#define INCLUDED_CUDA_THREADS

#include <pthread.h>
#include <cuda.h>
#include "Threads.h"
#include "CudaScheduler.h"
#include "Sem.h"


class CudaScheduler;

typedef struct cuda_arg {
    int cpuid;
    // should be syncrhonized
    CudaScheduler *scheduler;
    TaskManagerImpl *manager;
    SemPtr wait;
    int useRefDma;
} cuda_thread_arg_t;

class CudaThreads : public Threads {

 public:
    /*
      static GpuThreads* getInstance() {
      static GpuThreads singleton;
      return &singleton;
      }*/
    CudaThreads(int useRefDma);
    ~CudaThreads();
    
    void init();
    static void *cuda_thread_run(void *args);
    virtual int spawn_task(int cpu_num, TaskListPtr p);
    virtual void set_mail_waiter(SemPtr w);

    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:
    cuda_thread_arg_t *args;
    pthread_t *threads;
    int use_refdma;
};

#endif