view TaskManager/kernel/ppe/CpuThreads.h @ 1963:6988e5478a8c draft

fix CudaScheduler
author Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
date Wed, 12 Feb 2014 17:56:40 +0900
parents 777bdbf6c072
children a68dbdf9b429
line wrap: on
line source

#ifndef INCLUDED_CPU_THREADS
#define INCLUDED_CPU_THREADS

#include <pthread.h>
#include "Threads.h"
#include "GpuThreads.h"
#include "CudaThreads.h"
#include "TaskManagerImpl.h"
#include "MainScheduler.h"
#include "Sem.h"

typedef struct cpu_arg {
    int cpuid;
    int id_offset;
    int cpu_num;
    struct sched_param priority;
    // should be syncrhonized
    MainScheduler *scheduler;
    TaskManagerImpl *manager;
    SemPtr wait;
    int useRefDma;
    
} cpu_thread_arg_t;

//class GpuThreads;

class CpuThreads : public Threads {
 public:
    /* constructor */
    CpuThreads(int num = 1, int i_num = 0, int useRefDma = 0, int start_id = 0);
    ~CpuThreads();
    static void *cpu_thread_run(void *args);
    
    /* functions */
    virtual void init();
    virtual int get_mail(int speid, int count, memaddr *ret); // BLOCKING
    virtual int has_mail(int speid, int count, memaddr *ret); // NONBLOCK
    virtual void send_mail(int speid, int num, memaddr *data); // BLOCKING
    virtual void add_output_tasklist(int command, memaddr buff, int alloc_size);
    virtual int is_gpu(int cpuid);
    virtual int spawn_task(int cpu_num,TaskListPtr p);
    virtual void set_mail_waiter(SemPtr w);
    /* variables */
    pthread_t *threads;
    cpu_thread_arg_t *args;
    SemPtr wait; //スレッド生成時の待ち用
    int cpu_num;
    int io_num;	// high priority thread for IO
    int use_refdma;
    int id_offset;
#ifdef __CERIUM_GPU__
    GpuThreads *gpu;
#endif
#ifdef __CERIUM_CUDA__
    CudaThreads *gpu;
#endif    
};

#endif