device.h

[code="java"][/code]#ifndef DEVICE_H
#define DEVICE_H

#include <string.h>
#include <cstdlib>
#include <iostream>
#include <string>
#include <fstream>
#include <time.h>
#include <CL/opencl.h>

#ifdef _WIN32
#include <windows.h>
#else
#include <sys/time.h>
#include <linux/limits.h>
#endif

#define SDK_SUCCESS 0
#define SDK_FAILURE 1
#define WIDTH 128*1024
#define HEIGHT 512
#define NUM_THREADS 128*1024*512
#define NUM_GROUP_THREADS 1024*512
#define GROUP 128

//macro function for opencl API check.
#define CHECK_CL_ERROR(status,msg)\
if (CL_SUCCESS != status )\
{\
std::cout<<"Error:"<<msg<<std::endl;\
return SDK_FAILURE;\
}

/* Timer class to handle time measuring functionality */
class Timer
{
public:
int createTimer();
int startTimer();
int resetTimer();
int stopTimer();
double readTimer();
private:
long long _freq; // clock frequency
long long _clocks;// number of ticks at end
long long _start;//start point ticks
double totaltime;//time elapsed
};

class Device
{
public:

//CL Objects and memory buffers
int status;
cl_device_type dType; //device type
cl_device_id deviceId; //device ID
cl_context context; //context
cl_command_queue queue; //command-queue
cl_mem inputBuffer; //input buffer
cl_mem outputBuffer; //output buffer
cl_program program; //program object
cl_kernel kernel; //kernel object
cl_event eventObject; //event object

cl_ulong kernelStartTime; //kernel start time
cl_ulong kernelEndTime; //kernel end time
double elapsedTime; //elapsed time in ms
cl_int eventStatus; //command queue event status flag
size_t globalThreads[2] ;
size_t localThreads[2] ;

Device();
~Device();

};
#endif /* #ifndef MULTI_GPU_H */
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值