view TaskManager/kernel/ppe/CpuThreads.h @ 1561:e8c9a7099bcc draft

add set NDRange param
author Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
date Tue, 12 Mar 2013 16:52:49 +0900
parents 622a7d053537
children 8ee897303cd0
line wrap: on
line source

#ifndef INCLUDED_CPU_THREADS
#define INCLUDED_CPU_THREADS

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

typedef struct cpu_arg {
    int cpuid;
    // 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 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 void set_NDRange(void *ndr);
private:
    /* variables */
    pthread_t *threads;
    cpu_thread_arg_t *args;
    SemPtr wait; //スレッド生成時の待ち用
    int cpu_num;
    int use_refdma;
    int id_offset;
    GpuThreads *gpu;
};

#endif