• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ checkError函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中checkError函数的典型用法代码示例。如果您正苦于以下问题:C++ checkError函数的具体用法?C++ checkError怎么用?C++ checkError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了checkError函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: allocateHostMemoryBluesteins

void 
allocateHostMemoryBluesteins(const unsigned n, const unsigned m)
{
    
  h_Hreal = (float *) malloc(sizeof(float) * m);
  checkError((h_Hreal != NULL), shrTRUE, "Could not allocate memory");
    
  h_Himag = (float *) malloc(sizeof(float) * m);
  checkError((h_Himag != NULL), shrTRUE, "Could not allocate memory");
  
  h_Yreal = (float *) malloc(sizeof(float) * m);
  checkError((h_Yreal != NULL), shrTRUE, "Could not allocate memory");
    
  h_Yimag = (float *) malloc(sizeof(float) * m);
  checkError((h_Yimag != NULL), shrTRUE, "Could not allocate memory");
  
  h_Zreal = (float *) malloc(sizeof(float) * m);
  checkError((h_Zreal != NULL), shrTRUE, "Could not allocate memory");
    
  h_Zimag = (float *) malloc(sizeof(float) * m);
  checkError((h_Zimag != NULL), shrTRUE, "Could not allocate memory");
  
  h_Xreal = (float *) malloc(sizeof(float) * m);
  checkError((h_Xreal != NULL), shrTRUE, "Could not allocate memory");
    
  h_Ximag = (float *) malloc(sizeof(float) * m);
  checkError((h_Ximag != NULL), shrTRUE, "Could not allocate memory");


  for(unsigned i =0; i< m ; i++)
    {
      h_Xreal[i]=0;
      h_Ximag[i]=0;
    }
  h_Xreal[0]=1;
  h_Ximag[0]=1;

  //Precomputation. 

  const float TWOPI = 2*3.14159265358979323846;
  const float theta =  TWOPI / (2 * n);

  for(int l = 0; l < n; l++)
    {
      float c = cos( -1 *theta * l *l);
      float s = sin( -1 *theta * l*l);

      //Toeplitz matrix
      h_Hreal[l] = c;
      h_Himag[l] = s;

      //Y_l Since W_n^-l*l/2
      h_Yreal[l] = h_Xreal[l] * c + h_Ximag[l] * s;
      h_Yimag[l] = h_Ximag[l] *c -  h_Xreal[l] * s;
    }

  for(int i=n; i< m -n +1 ; i++)
    {
      h_Hreal[i] = 0; 
      h_Himag[i] = 0;
      h_Yreal[i] = 0;
      h_Yimag[i] = 0;
    }

  for(int i = m -n +2 ; i < m ; i++)
    {
      h_Hreal[i] = h_Hreal[m-i]; 
      h_Himag[i] = h_Himag[m-i];
      h_Yreal[i] = 0;
      h_Yimag[i] = 0;
    }
}
开发者ID:rzel,项目名称:clfft,代码行数:72,代码来源:bluestein.cpp


示例2: blendEquationSeparatei

//! glBlendEquationSeparatei wrapper. May throw.
inline void blendEquationSeparatei(GLuint const buf, GLenum const mode_rgb,
                                   GLenum const mode_alpha)
{
  glBlendEquationSeparatei(buf, mode_rgb, mode_alpha);
  checkError("glBlendEquationSeparatei");
}
开发者ID:thinks,项目名称:nDjinn,代码行数:7,代码来源:nDjinnFunctions.hpp


示例3: cullFace

inline void cullFace(GLenum const mode)
{
  glCullFace(mode);
  checkError("glCullFace");
}
开发者ID:thinks,项目名称:nDjinn,代码行数:5,代码来源:nDjinnFunctions.hpp


示例4: clearBufferuiv

//! glClearBufferuiv wrapper. May throw.
inline void clearBufferuiv(GLenum const buf,
                           GLint const drawbuffer,
                           GLuint const* value) {
  glClearBufferuiv(buf, drawbuffer, value);
  checkError("glClearBufferuiv");
}
开发者ID:thinks,项目名称:nDjinn,代码行数:7,代码来源:nDjinnFunctions.hpp


示例5: readBuffer

//! glReadBuffer wrapper. May throw.
inline void readBuffer(GLenum const mode)
{
  glReadBuffer(mode);
  checkError("glReadBuffer");
}
开发者ID:thinks,项目名称:nDjinn,代码行数:6,代码来源:nDjinnFunctions.hpp


示例6: blendEquationSeparate

//! glBlendEquationSeparate wrapper. May throw.
inline void blendEquationSeparate(GLenum const mode_rgb,
                                  GLenum const mode_alpha)
{
  glBlendEquationSeparate(mode_rgb, mode_alpha);
  checkError("glBlendEquationSeparate");
}
开发者ID:thinks,项目名称:nDjinn,代码行数:7,代码来源:nDjinnFunctions.hpp


示例7: clearDepthf

//! glClearDepthf wrapper. May throw. 
inline void clearDepthf(GLclampf const d) {
  glClearDepthf(d);
  checkError("glClearDepthf");
}
开发者ID:thinks,项目名称:nDjinn,代码行数:5,代码来源:nDjinnFunctions.hpp


示例8: isEnabled

//! glIsEnabled wrapper. May throw. 
inline GLboolean isEnabled(GLenum const cap) {
  const GLboolean enabled = glIsEnabled(cap);
  checkError("glIsEnabled");
  return enabled;
}
开发者ID:thinks,项目名称:nDjinn,代码行数:6,代码来源:nDjinnFunctions.hpp


示例9: getString

//! glGetString wrapper. May throw.
inline const GLubyte* getString(GLenum const name) {
  GLubyte const* str = glGetString(name);
  checkError("glGetString");
  return str;
}
开发者ID:thinks,项目名称:nDjinn,代码行数:6,代码来源:nDjinnFunctions.hpp


示例10: getFloatv

//! glGetFloatv wrapper. May throw. 
inline void getFloatv(GLenum const pname, GLfloat* data) {
  glGetFloatv(pname, data);
  checkError("glGetFloatv");
}
开发者ID:thinks,项目名称:nDjinn,代码行数:5,代码来源:nDjinnFunctions.hpp


示例11: getDoublev

//! glGetDoublev wrapper. May throw.
inline void getDoublev(GLenum const pname, GLdouble* data) {
  glGetDoublev(pname, data);
  checkError("glGetDoublev");
}
开发者ID:thinks,项目名称:nDjinn,代码行数:5,代码来源:nDjinnFunctions.hpp


示例12: getInteger64v

//! glGetInteger64v wrapper. May throw.
inline void getInteger64v(GLenum const pname, GLint64* data) {
  glGetInteger64v(pname, data);
  checkError("glGetInteger64v");
}
开发者ID:thinks,项目名称:nDjinn,代码行数:5,代码来源:nDjinnFunctions.hpp


示例13: getBooleanv

//! glGetBooleanv wrapper. May throw.
inline void getBooleanv(GLenum const pname, GLboolean* data) {
  glGetBooleanv(pname, data);
  checkError("glGetBooleanv");
}
开发者ID:thinks,项目名称:nDjinn,代码行数:5,代码来源:nDjinnFunctions.hpp


示例14: main

int main(int argc, char** argv)
{
    cl_int          err;               // error code returned from OpenCL calls

    size_t dataSize = sizeof(float) * LENGTH;
    float*       h_a = (float *)malloc(dataSize);       // a vector
    float*       h_b = (float *)malloc(dataSize);       // b vector
    float*       h_c = (float *)malloc(dataSize);       // c vector (result)
    float*       h_d = (float *)malloc(dataSize);       // d vector (result)
    float*       h_e = (float *)malloc(dataSize);       // e vector
    float*       h_f = (float *)malloc(dataSize);       // f vector (result)
    float*       h_g = (float *)malloc(dataSize);       // g vector
    unsigned int correct;           // number of correct results

    size_t global;                  // global domain size

    cl_device_id     device_id;     // compute device id
    cl_context       context;       // compute context
    cl_command_queue commands;      // compute command queue
    cl_program       program;       // compute program
    cl_kernel        ko_vadd;       // compute kernel

    cl_mem d_a;                     // device memory used for the input  a vector
    cl_mem d_b;                     // device memory used for the input  b vector
    cl_mem d_c;                     // device memory used for the output c vector
    cl_mem d_d;                     // device memory used for the output d vector
    cl_mem d_e;                     // device memory used for the input e vector
    cl_mem d_f;                     // device memory used for the output f vector
    cl_mem d_g;                     // device memory used for the input g vector

    // Fill vectors a and b with random float values
    int i = 0;
    for(i = 0; i < LENGTH; i++){
        h_a[i] = rand() / (float)RAND_MAX;
        h_b[i] = rand() / (float)RAND_MAX;
        h_e[i] = rand() / (float)RAND_MAX;
        h_g[i] = rand() / (float)RAND_MAX;
    }

    // Set up platform and GPU device

    cl_uint numPlatforms;

    // Find number of platforms
    err = clGetPlatformIDs(0, NULL, &numPlatforms);
    checkError(err, "Finding platforms");
    if (numPlatforms == 0)
    {
        printf("Found 0 platforms!\n");
        return EXIT_FAILURE;
    }

    // Get all platforms
    cl_platform_id Platform[numPlatforms];
    err = clGetPlatformIDs(numPlatforms, Platform, NULL);
    checkError(err, "Getting platforms");

    // Secure a GPU
    for (i = 0; i < numPlatforms; i++)
    {
        err = clGetDeviceIDs(Platform[i], DEVICE, 1, &device_id, NULL);
        if (err == CL_SUCCESS)
        {
            break;
        }
    }

    if (device_id == NULL)
        checkError(err, "Getting device");

    err = output_device_info(device_id);
    checkError(err, "Outputting device info");
  
    // Create a compute context 
    context = clCreateContext(0, 1, &device_id, NULL, NULL, &err);
    checkError(err, "Creating context");

    // Create a command queue
    commands = clCreateCommandQueue(context, device_id, 0, &err);
    checkError(err, "Creating command queue");

    // Create the compute program from the source buffer
    program = clCreateProgramWithSource(context, 1, (const char **) & KernelSource, NULL, &err);
    checkError(err, "Creating program");

    // Build the program  
    err = clBuildProgram(program, 0, NULL, NULL, NULL, NULL);
    if (err != CL_SUCCESS)
    {
        size_t len;
        char buffer[2048];

        printf("Error: Failed to build program executable!\n%s\n", err_code(err));
        clGetProgramBuildInfo(program, device_id, CL_PROGRAM_BUILD_LOG, sizeof(buffer), buffer, &len);
        printf("%s\n", buffer);
        return EXIT_FAILURE;
    }

    // Create the compute kernel from the program 
    ko_vadd = clCreateKernel(program, "vadd", &err);
//.........这里部分代码省略.........
开发者ID:BenElgar,项目名称:Exercises-Solutions,代码行数:101,代码来源:vadd_chain.c


示例15: stencilMaskSeparate

//! glStencilMaskSeparate wrapper. May throw.
inline void stencilMaskSeparate(GLenum const face, GLuint const mask) {
  glStencilMaskSeparate(face, mask);
  checkError("glStencilMaskSeparate");
}
开发者ID:thinks,项目名称:nDjinn,代码行数:5,代码来源:nDjinnFunctions.hpp


示例16: vertexAttribDivisor

//! glVertexAttribDivisor wrapper. May throw.
inline void vertexAttribDivisor(GLuint const index, GLuint const divisor) {
  glVertexAttribDivisor(index, divisor);
  checkError("glVertexAttribDivisor");
}
开发者ID:thinks,项目名称:nDjinn,代码行数:5,代码来源:nDjinnFunctions.hpp


示例17: clear

//! glClear wrapper. May throw.
inline void clear(GLbitfield const buf) {
  glClear(buf);
  checkError("glClear");        
}
开发者ID:thinks,项目名称:nDjinn,代码行数:5,代码来源:nDjinnFunctions.hpp


示例18: depthRange

//! glDepthRange wrapper. May throw.
inline void depthRange(GLclampd const n, GLclampd const f) {
  glDepthRange(n, f);
  checkError("glDepthRange");
}
开发者ID:thinks,项目名称:nDjinn,代码行数:5,代码来源:nDjinnFunctions.hpp


示例19: clearDepth

//! glClearDepth wrapper. May throw.
inline void clearDepth(GLclampd const d) {
  glClearDepth(d);
  checkError("glClearDepth");
}
开发者ID:thinks,项目名称:nDjinn,代码行数:5,代码来源:nDjinnFunctions.hpp


示例20: drawBuffer

//! glDrawBuffer wrapper. May throw.
inline void drawBuffer(GLenum const buf)
{
  glDrawBuffer(buf);
  checkError("glDrawBuffer");
} 
开发者ID:thinks,项目名称:nDjinn,代码行数:6,代码来源:nDjinnFunctions.hpp



注:本文中的checkError函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ checkErrors函数代码示例发布时间:2022-05-30
下一篇:
C++ checkErr函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap