Git Product home page Git Product logo

openclipp's Introduction

OpenCLIPP - OpenCL Integrated Performance Primitives

OpenCLIPP is a library providing processing primitives (image processing and computer vision primitives) implemented with OpenCL for fast execution on dedicated computing devices like GPUs.

It was designed to be simple to use and to have low overhead.

Two interfaces are provided :

  • C Interface similar to the Intel IPP and NVIDIA NPP libraries

  • C++ Interface

Requirements

An OpenCL SDK is required to build the library. OpenCL SDKs are available for download from Intel, AMD and NVIDIA

How to build

  • On Windows : Use the .sln file with Visual Studio 2015
  • Other platforms : Use make with the provided makefiles:
user@machine ~/OpenCLIPP# make

How to use it - C++

#include "OpenCLIPP.hpp"

// Initialize OpenCL
COpenCL CL;    
COpenCL::SetClFilesPath("/path/to/cl files/");

// Fill a SImage structure with image information
SImage SomeImage = {width, height, step, channels, type);

// Create an image in the device
//  Image data is not sent to the device
Image Img1(CL, SomeImage, Image1DataPtr);

// Create a second image in the device
Image Img2(CL, SomeImage, Image2DataPtr);

// Create an OpenCL program to do arithmetic operations
Arithmetic arithmetic(CL);

// Will add 10 to each pixel value and put the result in Img2 in the device
//  Img1 is automatically sent to the device, before the calculation, since it was not sent previously.
//  The memory transfer and calculation are done asynchronously.
arithmetic.Add(Img1, Img2, 10);

// Ask to read Img2, after previous operations are done.
//  true as argument means we want to wait for the transfer to finish.
//  After this statement, the result of the computation will be in Image2DataPtr.
Img2.Read(true);

// The image now contains the result of the addition

How to use it - C

#include <OpenCLIPP.h>

/* Variables */
ocipContext Context = NULL;
ocipError Error = CL_SUCCESS;
ocipImage Img1, Img2;

/* Initialize OpenCL */
Error = ocipInitialize(&Context, NULL, CL_DEVICE_TYPE_ALL);
ocipSetCLFilesPath("/path/to/cl files/");

/* Fill a SImage structure with image information */
SImage SomeImage = {width, height, step, channels, type};

/* Create an image in the device
   Image data is not sent to the device */
Error = ocipCreateImage(&Img1, SomeImage, Image1DataPtr, CL_MEM_READ_ONLY);

/* Create a second image in the device */
Error = ocipCreateImage(&Img2, SomeImage, Image2DataPtr, CL_MEM_WRITE_ONLY);

/* Will add 10 to each pixel value of Img1 and put the result in Img2 in the device
    Img1 is automatically sent to the device, before the calculation, since it was not sent previously.
    The memory transfer and calculation are done asynchronously. */
Error = ocipAddC(Img1, Img2, 10);

/* Ask to read Img2, after previous operations are done.
   After this statement, the result of the computation will be in Image2DataPtr. */
Error = ocipReadImage(Img2);

/* Free images on the device */
Error = ocipReleaseImage(Img1);
Error = ocipReleaseImage(Img2);

/* Uninitialize */
Error = ocipUninitialize(Context);

Error handling - C++

When using the C++ interface, errors are reported using C++ exceptions : an instance of cl::Error is thrown The cl::Error will contain :

  • a numerical error code (cl::Error.err()) that can be translated to text using COpenCL::ErrorName()
  • optionally an explanatory string (cl::Error.what())

Error handling - C

Most functions of the C interface return a ocipError. When no error occured, the value returned will be CL_SUCCESS (0). When an error occurs, a negative value will be returned. The error value can be translated to text using ocipGetErrorName().

Similarity with IPP & NPP

OpenCLIPP provides a C interface that can is similar to the popular libraries Intel IPP and NVIDIA NPP. Except unlike these libraries, the OpenCLIPP library tracks images in the computing device using objects that know size, datatype and number of channels of the image. This leads to simpler function signatures than IPP and NPP (less arguments and no need for complex suffixes).

Typical primitive signature

/*IPP*/			IppStatus ippiAbsDiffC_8u_C1R(const Ipp8u* pSrc,  int srcStep,   Ipp8u* pDst, int dstStep,  IppiSize roiSize,  int value);
/*NPP*/			NppStatus nppiAbsDiffC_8u_C1R(const Npp8u* pSrc1, int nSrc1Step, Npp8u* pDst, int nDstStep, NppiSize oSizeROI, Npp8u nConstant);
/*OpenCLIPP*/	ocipError ocipAbsDiffC(ocipImage Source, ocipImage Dest, float value);

Supported image types

The library supports the following image types:

  • 2 dimensions, no size restrictions (size restrictions may be present for some primitives, like <16megapixels for FFT)
  • Signed or Unsigned integer of 8, 16 or 32 bits
  • Floating point 32 and 64 bits
  • 1, 2, 3 or 4 channels (all channels must be the same type)

Supported platforms

Supported OpenCL platforms :

  • nVidia
  • AMD
  • Intel (tested only on CPU)

Supported Operating Systems :

  • Windows 7+
  • Linux (tested on Ubuntu with AMD)

Currently implemented primitives

  • Arithmetic and Logic
  • LUT
  • Morphology
  • Transform (Mirror, Flip & Transpose)
  • Resize and Rotate
  • Datatype conversion & value scaling
  • Treshold
  • Filters (Blur, Sharpen, Sobel, Median, etc.)
  • Histogram
  • Pattern matching
  • Statistical reductions
  • Blob labeling
  • Integral scan
  • FFT (using external library clFFT)
  • ...

Performance

Performance is significantly higher than IPP when operating on big (2048x2048+) images and using a high end GPU (expect 3 to 10x faster for most operations). Performance is comparable and often slightly better than NPP on the same GPU (sometimes as much as 2x faster). The library has the advantage of being able to run on AMD GPUs that usually provide significantly better OpenCL performance than NVIDIA GPUs. No device specific optimization has been done so performance of many primitives can be further improved.

Authors

  • Antoine W. Campagna
  • Gao Chen

Call for contributions

We will welcome comments and contributions to improve the library. Please send us your contributions via pull requests.

Comments or questions

License

The OpenCLIPP is free for personal and commercial use. It is released under the LGPL license, see the file named 'LICENSE' for details.

Publications

If you are using the library in published work, please refer to the following paper:

M. Akhloufi, A. Campagna, "OpenCLIPP: OpenCL Integrated Performance Primitives library for computer vision applications", Proc. SPIE Electronic Imaging 2014, Intelligent Robots and Computer Vision XXXI: Algorithms and Techniques, P. 9025-31, San Francisco, CA, USA, February 2014.

openclipp's People

Contributors

antagna avatar jeffheifetz avatar moulay-akhloufi avatar szagoruyko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

openclipp's Issues

how to use method of blob

how to use mehtod of blob?
i can not get the correct result with it.
do u have a demo about it .

appreciate it

Compiling an executable Demo on Ubuntu

Hello dear developers,

I'm trying to run your code on my Ubuntu 16.04 system with CUDA SDK(which includes OpenCL) installed.
So far I have been able to build your code successfully.
However I'm struggling to get the code to actually run as executable.

Which compiler should I use (gcc/g++/nvcc) and what options should I specify to generate an executable file?
Are there any further adjustments, that I have to make in order to actually test your code?
E.g. in the Demo.cpp file references some "lena.png" file that is not included in the repository.

Many thanks

Best regards,
Yaroslav

Wrong results from Inverse FFT

FFT transforms have recently been added to the OpenCLIPP, using the clFFT library.
Forward FFT transform works as expected

But inverse FFT results differ significantly from those obtained from Intel IPP.

Inverse FFT was tested on NVIDIA and Intel hardware and the same result was observed.
The result obtained is also the same as the one given by OpenCL OCV which also uses clFFT.
So it looks like the problem is in clFFT.

More tests should be done to narrow the problem :

  • On AMD platform
  • Using more simple values
  • Verify 1D transform
  • Create a simple test program to reproduce problem & report bug

Can't run demo on OS/X

I made the following changes in an attempt to get the demo running, but it seems to fail on kernel compilation.

Is this an issue on other platforms?

Using device : Intel(R) Core(TM) i7-4578U CPU @ 3.00GHz
Program build failed : <program source>:38:4: warning: unused variable 'pos'
   BEGIN
   ^
<program source>:32:15: note: expanded from macro 'BEGIN'
   const int2 pos = { gx, gy };
              ^
<program source>:51:4: warning: unused variable 'pos'
   BEGIN
   ^
<program source>:32:15: note: expanded from macro 'BEGIN'
   const int2 pos = { gx, gy };
              ^
<program source>:154:1: warning: implicit declaration of function 'convert___uchar3_sat' is invalid in C99
CONVERT_KERNEL(to_uchar,   CONCATENATE(uchar,  NBCHAN))
^
<program source>:120:46: note: expanded from macro 'CONVERT_KERNEL'
      dest[gy * dst_step + gx] = CONCATENATE(convert_, CONCATENATE(dest_type, _sat)) (src);\
                                             ^
/Users/jeffheifetz/Coding/Bubl/BublEqui/extern/OpenCLIPP/Demo/../cl-files/Base.h:46:40: note: expanded from macro 'CONCATENATE'
#define CONCATENATE(a, b) _CONCATENATE(a, b)
                                       ^
/Users/jeffheifetz/Coding/Bubl/BublEqui/extern/OpenCLIPP/Demo/../cl-files/Base.h:47:28: note: expanded from macro '_CONCATENATE'
#define _CONCATENATE(a, b) a ## b
                           ^
<scratch space>:13:1: note: expanded from macro 'convert_'
convert___uchar3_sat
^
<program source>:154:1: warning: unused variable 'pos'
CONVERT_KERNEL(to_uchar,   CONCATENATE(uchar,  NBCHAN))
^
<program source>:116:7: note: expanded from macro 'CONVERT_KERNEL'
      BEGIN\
      ^
<program source>:32:15: note: expanded from macro 'BEGIN'
   const int2 pos = { gx, gy };
              ^
<program source>:155:1: warning: implicit declaration of function 'convert___char3_sat' is invalid in C99
CONVERT_KERNEL(to_char,    CONCATENATE(char,   NBCHAN))
^
<program source>:120:46: note: expanded from macro 'CONVERT_KERNEL'
      dest[gy * dst_step + gx] = CONCATENATE(convert_, CONCATENATE(dest_type, _sat)) (src);\
                                             ^
/Users/jeffheifetz/Coding/Bubl/BublEqui/extern/OpenCLIPP/Demo/../cl-files/Base.h:46:40: note: expanded from macro 'CONCATENATE'
#define CONCATENATE(a, b) _CONCATENATE(a, b)
                                       ^
/Users/jeffheifetz/Coding/Bubl/BublEqui/extern/OpenCLIPP/Demo/../cl-files/Base.h:47:28: note: expanded from macro '_CONCATENATE'
#define _CONCATENATE(a, b) a ## b
                           ^
<scratch space>:13:1: note: expanded from macro 'convert_'
convert___char3_sat
^
<program source>:155:1: warning: unused variable 'pos'
CONVERT_KERNEL(to_char,    CONCATENATE(char,   NBCHAN))
^
<program source>:116:7: note: expanded from macro 'CONVERT_KERNEL'
      BEGIN\
      ^
<program source>:32:15: note: expanded from macro 'BEGIN'
   const int2 pos = { gx, gy };
              ^
<program source>:156:1: warning: implicit declaration of function 'convert___ushort3_sat' is invalid in C99
CONVERT_KERNEL(to_ushort,  CONCATENATE(ushort, NBCHAN))
^
<program source>:120:46: note: expanded from macro 'CONVERT_KERNEL'
      dest[gy * dst_step + gx] = CONCATENATE(convert_, CONCATENATE(dest_type, _sat)) (src);\
                                             ^
/Users/jeffheifetz/Coding/Bubl/BublEqui/extern/OpenCLIPP/Demo/../cl-files/Base.h:46:40: note: expanded from macro 'CONCATENATE'
#define CONCATENATE(a, b) _CONCATENATE(a, b)
                                       ^
/Users/jeffheifetz/Coding/Bubl/BublEqui/extern/OpenCLIPP/Demo/../cl-files/Base.h:47:28: note: expanded from macro '_CONCATENATE'
#define _CONCATENATE(a, b) a ## b
                           ^
<scratch space>:13:1: note: expanded from macro 'convert_'
convert___ushort3_sat
^
<program source>:156:1: warning: unused variable 'pos'
CONVERT_KERNEL(to_ushort,  CONCATENATE(ushort, NBCHAN))
^
<program source>:116:7: note: expanded from macro 'CONVERT_KERNEL'
      BEGIN\
      ^
<program source>:32:15: note: expanded from macro 'BEGIN'
   const int2 pos = { gx, gy };
              ^
<program source>:157:1: warning: implicit declaration of function 'convert___short3_sat' is invalid in C99
CONVERT_KERNEL(to_short,   CONCATENATE(short,  NBCHAN))
^
<program source>:120:46: note: expanded from macro 'CONVERT_KERNEL'
      dest[gy * dst_step + gx] = CONCATENATE(convert_, CONCATENATE(dest_type, _sat)) (src);\
                                             ^
/Users/jeffheifetz/Coding/Bubl/BublEqui/extern/OpenCLIPP/Demo/../cl-files/Base.h:46:40: note: expanded from macro 'CONCATENATE'
#define CONCATENATE(a, b) _CONCATENATE(a, b)
                                       ^
/Users/jeffheifetz/Coding/Bubl/BublEqui/extern/OpenCLIPP/Demo/../cl-files/Base.h:47:28: note: expanded from macro '_CONCATENATE'
#define _CONCATENATE(a, b) a ## b
                           ^
<scratch space>:13:1: note: expanded from macro 'convert_'
convert___short3_sat
^
<program source>:157:1: warning: unused variable 'pos'
CONVERT_KERNEL(to_short,   CONCATENATE(short,  NBCHAN))
^
<program source>:116:7: note: expanded from macro 'CONVERT_KERNEL'
      BEGIN\
      ^
<program source>:32:15: note: expanded from macro 'BEGIN'
   const int2 pos = { gx, gy };
              ^
<program source>:158:1: warning: implicit declaration of function 'convert___uint3_sat' is invalid in C99
CONVERT_KERNEL(to_uint,    CONCATENATE(uint,   NBCHAN))
^
<program source>:120:46: note: expanded from macro 'CONVERT_KERNEL'
      dest[gy * dst_step + gx] = CONCATENATE(convert_, CONCATENATE(dest_type, _sat)) (src);\
                                             ^
/Users/jeffheifetz/Coding/Bubl/BublEqui/extern/OpenCLIPP/Demo/../cl-files/Base.h:46:40: note: expanded from macro 'CONCATENATE'
#define CONCATENATE(a, b) _CONCATENATE(a, b)
                                       ^
/Users/jeffheifetz/Coding/Bubl/BublEqui/extern/OpenCLIPP/Demo/../cl-files/Base.h:47:28: note: expanded from macro '_CONCATENATE'
#define _CONCATENATE(a, b) a ## b
                           ^
<scratch space>:13:1: note: expanded from macro 'convert_'
convert___uint3_sat
^
<program source>:158:1: warning: unused variable 'pos'
CONVERT_KERNEL(to_uint,    CONCATENATE(uint,   NBCHAN))
^
<program source>:116:7: note: expanded from macro 'CONVERT_KERNEL'
      BEGIN\
      ^
<program source>:32:15: note: expanded from macro 'BEGIN'
   const int2 pos = { gx, gy };
              ^
<program source>:159:1: warning: implicit declaration of function 'convert___int3_sat' is invalid in C99
CONVERT_KERNEL(to_int,     CONCATENATE(int,    NBCHAN))
^
<program source>:120:46: note: expanded from macro 'CONVERT_KERNEL'
      dest[gy * dst_step + gx] = CONCATENATE(convert_, CONCATENATE(dest_type, _sat)) (src);\
                                             ^
/Users/jeffheifetz/Coding/Bubl/BublEqui/extern/OpenCLIPP/Demo/../cl-files/Base.h:46:40: note: expanded from macro 'CONCATENATE'
#define CONCATENATE(a, b) _CONCATENATE(a, b)
                                       ^
/Users/jeffheifetz/Coding/Bubl/BublEqui/extern/OpenCLIPP/Demo/../cl-files/Base.h:47:28: note: expanded from macro '_CONCATENATE'
#define _CONCATENATE(a, b) a ## b
                           ^
<scratch space>:13:1: note: expanded from macro 'convert_'
convert___int3_sat
^
<program source>:159:1: warning: unused variable 'pos'
CONVERT_KERNEL(to_int,     CONCATENATE(int,    NBCHAN))
^
<program source>:116:7: note: expanded from macro 'CONVERT_KERNEL'
      BEGIN\
      ^
<program source>:32:15: note: expanded from macro 'BEGIN'
   const int2 pos = { gx, gy };
              ^
<program source>:160:1: warning: implicit declaration of function 'convert___float3' is invalid in C99
CONVERT_FLOAT_KERNEL(to_float,  CONCATENATE(float,  NBCHAN))
^
<program source>:130:46: note: expanded from macro 'CONVERT_FLOAT_KERNEL'
      dest[gy * dst_step + gx] = CONCATENATE(convert_, dest_type) (src);\
                                             ^
/Users/jeffheifetz/Coding/Bubl/BublEqui/extern/OpenCLIPP/Demo/../cl-files/Base.h:46:40: note: expanded from macro 'CONCATENATE'
#define CONCATENATE(a, b) _CONCATENATE(a, b)
                                       ^
/Users/jeffheifetz/Coding/Bubl/BublEqui/extern/OpenCLIPP/Demo/../cl-files/Base.h:47:28: note: expanded from macro '_CONCATENATE'
#define _CONCATENATE(a, b) a ## b
                           ^
<scratch space>:13:1: note: expanded from macro 'convert_'
convert___float3
^
<program source>:160:1: warning: unused variable 'pos'
CONVERT_FLOAT_KERNEL(to_float,  CONCATENATE(float,  NBCHAN))
^
<program source>:126:7: note: expanded from macro 'CONVERT_FLOAT_KERNEL'
      BEGIN\
      ^
<program source>:32:15: note: expanded from macro 'BEGIN'
   const int2 pos = { gx, gy };
              ^
<program source>:161:1: warning: implicit declaration of function 'convert___double3' is invalid in C99
CONVERT_FLOAT_KERNEL(to_double, CONCATENATE(double, NBCHAN))
^
<program source>:130:46: note: expanded from macro 'CONVERT_FLOAT_KERNEL'
      dest[gy * dst_step + gx] = CONCATENATE(convert_, dest_type) (src);\
                                             ^
/Users/jeffheifetz/Coding/Bubl/BublEqui/extern/OpenCLIPP/Demo/../cl-files/Base.h:46:40: note: expanded from macro 'CONCATENATE'
#define CONCATENATE(a, b) _CONCATENATE(a, b)
                                       ^
/Users/jeffheifetz/Coding/Bubl/BublEqui/extern/OpenCLIPP/Demo/../cl-files/Base.h:47:28: note: expanded from macro '_CONCATENATE'
#define _CONCATENATE(a, b) a ## b
                           ^
<scratch space>:13:1: note: expanded from macro 'convert_'
convert___double3
^
<program source>:161:1: warning: unused variable 'pos'
CONVERT_FLOAT_KERNEL(to_double, CONCATENATE(double, NBCHAN))
^
<program source>:126:7: note: expanded from macro 'CONVERT_FLOAT_KERNEL'
      BEGIN\
      ^
<program source>:32:15: note: expanded from macro 'BEGIN'
   const int2 pos = { gx, gy };
              ^
<program source>:163:1: warning: unused variable 'pos'
SCALE_KERNEL(scale_to_uchar,  CONCATENATE(uchar,  NBCHAN))
^
<program source>:136:7: note: expanded from macro 'SCALE_KERNEL'
      BEGIN\
      ^
<program source>:32:15: note: expanded from macro 'BEGIN'
   const int2 pos = { gx, gy };
              ^
<program source>:164:1: warning: unused variable 'pos'
SCALE_KERNEL(scale_to_char,   CONCATENATE(char,   NBCHAN))
^
<program source>:136:7: note: expanded from macro 'SCALE_KERNEL'
      BEGIN\
      ^
<program source>:32:15: note: expanded from macro 'BEGIN'
   const int2 pos = { gx, gy };
              ^
<program source>:165:1: warning: unused variable 'pos'
SCALE_KERNEL(scale_to_ushort, CONCATENATE(ushort, NBCHAN))
^
<program source>:136:7: note: expanded from macro 'SCALE_KERNEL'
      BEGIN\
      ^
<program source>:32:15: note: expanded from macro 'BEGIN'
   const int2 pos = { gx, gy };
              ^
<program source>:166:1: warning: unused variable 'pos'
SCALE_KERNEL(scale_to_short,  CONCATENATE(short,  NBCHAN))
^
<program source>:136:7: note: expanded from macro 'SCALE_KERNEL'
      BEGIN\
      ^
<program source>:32:15: note: expanded from macro 'BEGIN'
   const int2 pos = { gx, gy };
              ^
<program source>:167:1: warning: unused variable 'pos'
SCALE_KERNEL(scale_to_uint,   CONCATENATE(uint,   NBCHAN))
^
<program source>:136:7: note: expanded from macro 'SCALE_KERNEL'
      BEGIN\
      ^
<program source>:32:15: note: expanded from macro 'BEGIN'
   const int2 pos = { gx, gy };
              ^
<program source>:168:1: warning: unused variable 'pos'
SCALE_KERNEL(scale_to_int,    CONCATENATE(int,    NBCHAN))
^
<program source>:136:7: note: expanded from macro 'SCALE_KERNEL'
      BEGIN\
      ^
<program source>:32:15: note: expanded from macro 'BEGIN'
   const int2 pos = { gx, gy };
              ^
<program source>:169:1: warning: unused variable 'pos'
SCALE_FLOAT_KERNEL(scale_to_float,  CONCATENATE(float,  NBCHAN))
^
<program source>:147:7: note: expanded from macro 'SCALE_FLOAT_KERNEL'
      BEGIN\
      ^
<program source>:32:15: note: expanded from macro 'BEGIN'
   const int2 pos = { gx, gy };
              ^
<program source>:170:1: warning: unused variable 'pos'
SCALE_FLOAT_KERNEL(scale_to_double, CONCATENATE(double, NBCHAN))
^
<program source>:147:7: note: expanded from macro 'SCALE_FLOAT_KERNEL'
      BEGIN\
      ^
<program source>:32:15: note: expanded from macro 'BEGIN'
   const int2 pos = { gx, gy };
              ^
<program source>:174:4: warning: unused variable 'pos'
   BEGIN
   ^
<program source>:32:15: note: expanded from macro 'BEGIN'
   const int2 pos = { gx, gy };
              ^
<program source>:183:4: warning: unused variable 'pos'
   BEGIN
   ^
<program source>:32:15: note: expanded from macro 'BEGIN'
   const int2 pos = { gx, gy };
              ^
<program source>:196:4: warning: unused variable 'pos'
   BEGIN
   ^
<program source>:32:15: note: expanded from macro 'BEGIN'
   const int2 pos = { gx, gy };
              ^
<program source>:205:4: warning: unused variable 'pos'
   BEGIN
   ^
<program source>:32:15: note: expanded from macro 'BEGIN'
   const int2 pos = { gx, gy };
              ^
<program source>:213:4: warning: unused variable 'pos'
   BEGIN
   ^
<program source>:32:15: note: expanded from macro 'BEGIN'
   const int2 pos = { gx, gy };
              ^
<program source>:232:4: warning: unused variable 'pos'
   BEGIN
   ^
<program source>:32:15: note: expanded from macro 'BEGIN'
   const int2 pos = { gx, gy };
              ^
kernel referenced external symbol 'convert___char3_sat' which could not be found.
kernel referenced external symbol 'convert___double3' which could not be found.
kernel referenced external symbol 'convert___float3' which could not be found.
kernel referenced external symbol 'convert___int3_sat' which could not be found.
kernel referenced external symbol 'convert___short3_sat' which could not be found.
kernel referenced external symbol 'convert___uchar3_sat' which could not be found.
kernel referenced external symbol 'convert___uint3_sat' which could not be found.
kernel referenced external symbol 'convert___ushort3_sat' which could not be found.
�
 - in file : ../cl-files/Convert.cl
libc++abi.dylib: terminating with uncaught exception of type cl::Error: clBuildProgram

Issue with Histogram

I am trying to use the histogram program.. The code I am using is:

#include <OpenCLIPP.hpp>
#include "png/lodepng.h"

using namespace std;
using namespace OpenCLIPP;

uint CalculateStep(const SImage& Img);

int main(int argc, char *argv[])
{
string Filename = "lena.png";
SImage ImageInfo;
std::vector SourceData;
unsigned Status = lodepng::decode(SourceData, ImageInfo.Width,ImageInfo.Height, Filename, LCT_RGB);
if (Status == 0)
{
ImageInfo.Channels = 3;
ImageInfo.Type = SImage::U8;
ImageInfo.Step = CalculateStep(ImageInfo);
}

	printf("Check 1 \n");

	//Initialize OpenCL
	COpenCL CL;
	CL.SetClFilesPath("/home/kathleen/Downloads/OpenCLIPP-master/cl-files/");
	Histogram Histogram(CL);

	string Name = CL.GetDeviceName();
	printf("Using device : %s\n", Name.c_str());
	printf("Check 2 \n");
	//Create OpenCL image
	ColorImage SourceImage(CL, ImageInfo, SourceData.data());
	printf("Check 3 \n");

	SourceImage.Send();   
	//Histogram
	uint Histogramptr[256];
	
	Histogram.Histogram1C(SourceImage,Histogramptr);
	printf("Check 4 \n");
	
	return 0;
}

uint CalculateStep(const SImage& Img)
{
uint Depth = 4;
if (Img.Type < SImage::U16)
Depth = 1;
else if (Img.Type < SImage::U32)
Depth = 2;

return Img.Width * Img.Channels * Depth;
}
The error I get is:
Program build failed : :36:51: error: invalid address space for argument to __kernel function
kernel void histogram_1C(INPUT_SPACE const SCALAR source, global uint * hist, uint src_step)
^
:36:51: error: parameter may not be qualified with an address space
:73:49: error: invalid address space for argument to __kernel function
kernel void histogram_4C(INPUT_SPACE const TYPE source, global uint * hist, uint src_step)
^
:73:49: error: parameter may not be qualified with an address space

Thank you for your time.

some build error with vs2013

1,When I build this library with vs2013 and intel opencl sdk (opencl 2.0),"CL_USE_DEPRECATED_OPENCL_2_0_APIS" macro is request , or else will get a build error.

2,RandomImage.cpp Line48 , get a build error,modified to "std::uniform_int_distribution Dist(0, 0xFF);" is ok

3,Visual Studio support #pragma message

ifndef _MSC_VER // Visual Studio does not support #warning

warning "OpenCLIPP is not being built with clFFT - FFT operations will not be available"

else

pragma message("OpenCLIPP is not being built with clFFT - FFT operations will not be available")

endif

Library fails to build if recent official OpenCL headers are used

The library comes with its own set of OpenCL headers.
These headers are not the most recent OpenCL headers.

If the library is built using a recent version of the official OpenCL headers, the compilation fails.
The failure is due to an imcompatible change made in the cl.hpp file in recent versions of the official OpenCL headers.

Workaround :
Set your build environment to use the headers provided with the library

linux build errors

os: 3.18.7-100.fc20.x86_64

Building file: programs/ImageProximityFFT.cpp
g++ -g -O3 -Wall -c -fmessage-length=0 -std=c++0x -fPIC -I../include -I../include/c++ -I/usr/include -MMD -MP -MF"build/programs/ImageProximityFFT.deps" -MT"build/programs/ImageProximityFFT.deps" -o "build/programs/ImageProximityFFT.o" "programs/ImageProximityFFT.cpp"
programs/ImageProximityFFT.cpp:277:6: error: prototype for ‘void OpenCLIPP::ImageProximityFFT::MatchSquareDiff(int, int, OpenCLIPP::Image&, float, OpenCLIPP::Image&)’ does not match any in class ‘OpenCLIPP::ImageProximityFFT’
 void ImageProximityFFT::MatchSquareDiff(int , int , Image& , float , Image& )
      ^
In file included from programs/ImageProximityFFT.cpp:29:0:
../include/c++/Programs/ImageProximityFFT.h:95:9: error: candidate is: void OpenCLIPP::ImageProximityFFT::MatchSquareDiff(int, int, OpenCLIPP::Image&, double*, OpenCLIPP::Image&)
    void MatchSquareDiff(int width, int hight, Image& Source, double * templ_sqsum, Image& Dest);
         ^
programs/ImageProximityFFT.cpp:280:6: error: prototype for ‘void OpenCLIPP::ImageProximityFFT::MatchSquareDiffNorm(int, int, OpenCLIPP::Image&, float, OpenCLIPP::Image&)’ does not match any in class ‘OpenCLIPP::ImageProximityFFT’
 void ImageProximityFFT::MatchSquareDiffNorm(int , int , Image& , float , Image& )
      ^
In file included from programs/ImageProximityFFT.cpp:29:0:
../include/c++/Programs/ImageProximityFFT.h:98:9: error: candidate is: void OpenCLIPP::ImageProximityFFT::MatchSquareDiffNorm(int, int, OpenCLIPP::Image&, double*, OpenCLIPP::Image&)
    void MatchSquareDiffNorm(int width, int hight, Image& Source, double * templ_sqsum, Image& Dest);
         ^
programs/ImageProximityFFT.cpp:283:6: error: prototype for ‘void OpenCLIPP::ImageProximityFFT::MatchCrossCorrNorm(int, int, OpenCLIPP::Image&, float, OpenCLIPP::Image&)’ does not match any in class ‘OpenCLIPP::ImageProximityFFT’
 void ImageProximityFFT::MatchCrossCorrNorm(int , int , Image& , float , Image& )
      ^
In file included from programs/ImageProximityFFT.cpp:29:0:
../include/c++/Programs/ImageProximityFFT.h:101:9: error: candidate is: void OpenCLIPP::ImageProximityFFT::MatchCrossCorrNorm(int, int, OpenCLIPP::Image&, double*, OpenCLIPP::Image&)
    void MatchCrossCorrNorm(int width, int hight, Image& Source, double * templ_sqsum, Image& Dest);
         ^
make[1]: *** [build/programs/ImageProximityFFT.o] Error 1
make[1]: Leaving directory `/opt/code/OpenCLIPP/C++'
make: *** [C++] Error 2

Bench fails to link in Visual Studio

The GPUBench program fails to link in Visual Studio unless the proper versions of the .lib files of OpenCV are present.

Error message :
1>LINK : fatal error LNK1181: cannot open input file 'opencv_core246.lib'

Wrong result when both a "flush" image and a "non-flush" image are used at the same time as argument for a vector operation

Vector programs like ArithmeticVector have two versions. The standard (slower) program that can handle any images and the faster "flush" version that works only on some specific image sizes.

The flush version works correctly only with images that have :

  • no padding at the end of the lines
  • a width that is a multiple of the vector size

VectorProgram::SelectProgram() is used to select the proper program version. But SelectProgram

If a vector operation is called with a flush image as first argument and a non-flush images as second argument, the flush version of the program will be used, resulting in

Workaround : If you run into this problem, you can force the slow version by changing VectorProgram::SelectProgram() to :
Program& VectorProgram::SelectProgram(const ImageBase& Source)
{
if (Source.DataType() < 0 || Source.DataType() >= SImage::NbDataTypes)
throw cl::Error(CL_IMAGE_FORMAT_NOT_SUPPORTED, "unsupported image format used with ImageBufferProgram");

// Never use the fast version to prevent padding issues.
//if (IsImageFlush(Source))
// return GetProgram(Source.DataType()); // Use fast version

// Use slower WITH_PADDING version
return GetProgram(Source.DataType() + SImage::NbDataTypes);
}

VS build error

When building on VS an error occurs:

1>------ Build started: Project: OpenCLIPP-C++, Configuration: Debug Win32 ------
1> Program.cpp
1>c:\i+d\opencl\openclipp-master\openclipp-master\c++\programs\program.cpp(75): error C3861: 'IsDebuggerPresent': identifier not found
========== Build: 0 succeeded, 1 failed, 4 up-to-date, 0 skipped ==========

In program.cpp there is the code (line 50):

ifndef _MSC_VER

define IsDebuggerPresent() false

endif // _MSC_VER

And building fails as IsDebuggerPresent is not defined for VS compilers.

I suggest something like:

ifndef INTEL_CL_DEBUGGER

define IsDebuggerPresent() false

else

define IsDebuggerPresent() true

endif // INTEL_CL_DEBUGGER

The user can define the macro if debugging is wanted ( /D "INTEL_CL_DEBUGGER" ). Options added by this code are only supported by Intel SDK, so identifying by compiler is not an option as you can have VS with NVIDIA or AMD SDK.

C Demo does not work in Ubuntu

Hello, I have tried to run C++ and C demos in Ubuntu, C++ works fine but C Test-OpenCLIIPP gives black images on Intel and garbage on Nvidia. No filters work in C side in fact.
I wanted to run test but failed to compile them.

Test-OpenCLIPP produces unreadable image

Hi,

after some adjustment in make (include path to CL/cl.h for compiler) and source files (adjust absolute path to cl-files) I've successfully built the Test-OpenCLIPP sub-project.
I have also loaded the well-known lena.png image for test.
After running the code the code my GPU device is recognized and success is reported:
image
However the produced Result.png file includes an image which nowhere near resembles the input image.
I tried manipulating the filters and parameters with no success.
image

I also tried to just pass the SourceData to Return.png.
The result was no better.
Do you have an idea what could cause the problems?

Thanks!

Kind regards,
Yaroslav

Histogram Issue

When I run the four channel histogram program the first channel appears to be correct but the other three channels have values that are way too large. My code is below. Thank you for your time.
#include <OpenCLIPP.hpp>
#include "png/lodepng.h"

using namespace std;
using namespace OpenCLIPP;

uint CalculateStep(const SImage& Img);

int main(void)
{
// Load image from file
string FileName = "Skull.png";

	   SImage ImageInfo;
	   vector<unsigned char> SourceData;

	   unsigned Status = lodepng::decode(SourceData, ImageInfo.Width, ImageInfo.Height, FileName, LCT_RGBA);

	   if (Status == 0)
		{
			  // Load image from file succeded
			  ImageInfo.Channels = 4;
			  ImageInfo.Type = SImage::U8;
			  ImageInfo.Step = CalculateStep(ImageInfo);
		}
	//Initialize OpenCL
	COpenCL CL;
	CL.SetClFilesPath("/home/kathleen/Downloads/OpenCLIPP-master/cl-files/");
	

	string Name = CL.GetDeviceName();
	printf("Using device : %s\n", Name.c_str());
	
	//Create OpenCL image
	Image SourceImage(CL, ImageInfo, SourceData.data());

	SourceImage.Send(); 
	Histogram Histogram(CL);  
	//Histogram
	uint Histogramptr[1024];
	
	Histogram.Histogram1C(SourceImage,Histogramptr);
	FILE *file;
	const char* mode = "w";
	file = fopen("Results.txt",mode);
	for (int i = 0; i < 4; i++)
	{
		for(int j = 0; j < 256; j++)
		{
		 fprintf(file," %u ", Histogramptr[(i*256)+j]);
		}
		fprintf(file,"\n \n");
	}
	
	return 0;
}

Tresholding program not found

Tresholding program fails to compile because Tresholding.cl is not found

The file Treshold.cl should be named Tresholding.cl

TransformBuffer.cpp won't compile without Windows.h

When compiling in non-windows environment, max(a,b) is undefined.
This macro is defined in windows.h; you should not use it.
May I suggest that you define your own min and max macros, for maximum portability.

Wrong result when step of the image is not a multiple of the vector width for vector programs

Vector programs like ArithmeticVector gain speed by doing multiple operations at the same time.

But the current implementation accesses the wrong pixel if the step of the image is not a multiple of the vector length.

Workaround : Use the Image version of the programs if you run into this problem.

Solution : It should be possible to fix this by changing the pointer arithmetic in Vector.h

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.