2 Replies Latest reply on Sep 24, 2018 10:11 AM by dipak

    How to include external library in kernel?

    fresto

      I use a OpenCL for my operations and I already have 30 files that differ only in a couple of functions. I read about this problem on the forums and realized that before version OpenCL 2.1  i can not add my library to the kernel. Is it true? I need to use an external library in the kernel to add all the functions and use them in the main file. I have use AMD RX Vega 64. Sorry for my english.

        • Re: How to include external library in kernel?
          fresto

          I found that can add external library in the kernel, but need add path of library to cpp code. Can someone tell me, how to add clCreateProgramWithSource() in C++ with path of library?

          Thats part of my code

           

          std::ifstream sourceFile(name);

          std::string sourceCode(

          std::istreambuf_iterator<char>(sourceFile),

          (std::istreambuf_iterator<char>()));

          Program::Sources source(1, std::make_pair(sourceCode.c_str(), sourceCode.length() + 1));

           

          // Make program of the source code in the context

          Program program = Program(context, source);

           

          // Build program for these specific devices

           

          errcode = program.build(devices);

          if (errcode != CL_SUCCESS)

          {

          cout << "There were error during build kernel code. Please, check program code. Errcode = " << errcode << "\n";

          cout << "BUILD LOG: " + program.getBuildInfo<CL_PROGRAM_BUILD_LOG>(devices[0]) + "\n";

          getchar();

          return;

          }

           

          // Make kernel

          Kernel kernel(program, "vector_add");