- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
We are attempting to port our existing OpenCL application from Windows/Linux/Macintosh to the Cyclone 5 FPGA Development Board. We are using the ARM based cross compiler to compile our source code.
Our source code uses the OpenCL C++ API. I am getting compilation errors that I need to resolve. This is what I have tried so far:
// filename, "main.cpp"# if defined(OPENCL_CPP_API)# include <CL/cl.hpp># else# include <CL/cl.h># endif
int main(void)
{
return 0;
}
When I issue the following command (i.e., main.cpp uses the OpenCL C API) at the command line, it successfully compiles and produces an object file. --- Quote Start --- arm-linux-gnueabihf-g++ -IC:/altera/14.0/hld/host/include -c main.cpp --- Quote End --- However, when I issue the following command (i.e., main.cpp uses the OpenCL C++ API) at the command line, the compilation fails. --- Quote Start --- arm-linux-gnueabihf-g++ -IC:/altera/14.0/hld/host/include -c main.cpp -DOPENCL_CPP_API In file included from main.cpp:2:0: C:/altera/14.0/hld/host/include/CL/cl.hpp:160:19: fatal error: GL/gl.h: No such file or directory compilation terminated. --- Quote End --- Is there a compiler flags that I need to include? Or do I need to install another library? OpenGL perhaps? When we took the Altera training class for OpenCL optimization, the instructor assured me that the OpenCL C++ API is supported for the SoC platform. Any help would be appreciated.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I found the following "gl.h" files installed on my computer.
C:\altera\14.0\quartus\bin64\cygwin\usr\include\w32api\GL\gl.h C:\altera\14.0\modelsim_ase\gcc-4.2.1-mingw32vc9\include\GL\gl.h C:\altera\14.0\embedded\host_tools\cygwin\usr\include\w32api\GL\gl.h C:\altera\14.0\embedded\host_tools\cygwin\usr\x86_64-w64-mingw32\sys-root\mingw\include\GL\gl.h Do I include any of these directories when compiling? And if so, which one? I am using the following compiler: --- Quote Start --- C:\>arm-linux-gnueabihf-g++ --version arm-linux-gnueabihf-g++.exe (crosstool-NG linaro-1.13.1-4.7-2013.03-20130313 - Linaro GCC 2013.03) 4.7.3 20130226 (prerelease) Copyright (C) 2012 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --- Quote End ---- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I got a lot further in the process. I still have some outstanding questions I need answered but I figured I will document where I am at right now for someone else having my same problems.
Here is some sample code that I am compiling.
# include <string>
# include <iostream>
# include <sstream>
# include <CL/cl.hpp>
template<typename QueryType, typename ValueType>
void Log(QueryType& a_openclObject, cl_int a_propertyId, const std::string& a_propertyName, ValueType& a_value)
{
a_openclObject.getInfo(a_propertyId, &a_value);
std::stringstream os;
std::string spaces(40 - a_propertyName.size(), ' ');
os << a_propertyName << ":" << spaces << a_value << std::endl;
std::cout << os.str();
}
# define LOG(openclObject, openclProperty, value) Log(openclObject, openclProperty,# openclProperty, value);
int main(void)
{
// Find all the platforms on this computer...
std::vector<cl::Platform> platforms;
cl::Platform::get(&platforms);
for (size_t i=0; i<platforms.size(); ++i)
{
std::string valueString;
int valueInt;
unsigned int valueUint;
long long valueLongLong;
LOG(platforms, CL_PLATFORM_VENDOR, valueString);
// Now find out all the OpenCL devices supported for this platform...
std::vector<cl::Device> devices;
platforms.getDevices(CL_DEVICE_TYPE_ALL,&devices);
for (size_t j=0; j<devices.size(); ++j)
{
// Dump out the specific information for this device...
LOG(devices, CL_DEVICE_VERSION, valueString);
LOG(devices, CL_DRIVER_VERSION, valueString);
LOG(devices, CL_DEVICE_OPENCL_C_VERSION, valueString);
LOG(devices, CL_DEVICE_MAX_COMPUTE_UNITS, valueInt);
LOG(devices, CL_DEVICE_GLOBAL_MEM_SIZE, valueLongLong);
LOG(devices, CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE, valueLongLong);
LOG(devices, CL_DEVICE_LOCAL_MEM_SIZE, valueLongLong);
LOG(devices, CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE, valueLongLong);
LOG(devices, CL_DEVICE_MAX_CONSTANT_ARGS, valueLongLong);
LOG(devices, CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR, valueUint);
LOG(devices, CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR, valueUint);
LOG(devices, CL_DEVICE_ENDIAN_LITTLE, valueUint);
}
}
return 0;
}
Here is the makefile that I used.
all: main.exe
main.exe: main.o
arm-linux-gnueabihf-g++ -LC:\altera\14.0\hld\board\c5soc\arm32\lib -LC:/altera/14.0/hld/host/arm32/lib -lalteracl -lalterahalmmd -lalterammdpcie -lelf -lrt -lstdc++ -o main.exe main.o
main.o: main.cpp
arm-linux-gnueabihf-g++ -IC:/altera/14.0/hld/host/include -IC:\altera\14.0\quartus\bin64\cygwin\usr\include\w32api -c main.cpp
clean:
rm main.o main.exe
I was able to get passed the compilation error by including this line in the compilation step. --- Quote Start --- -IC:\altera\14.0\quartus\bin64\cygwin\usr\include\w32api --- Quote End --- Next step was to download the executable to the development board. However, when I ran the executable, I got this error. --- Quote Start --- ./main.exe: error while loading shared libraries: libalteracl.so: cannot open shared object file: No such file or directory --- Quote End --- Oops! I ran the initialization script again. --- Quote Start --- root@socfpga:~# source ./init_opencl.sh Error: could not insert module /home/root/opencl_arm32_rte/board/c5soc/driver/aclsoc_drv.ko: File exists --- Quote End --- It seems to fail BUT now my executable runs! Yeah! --- Quote Start --- root@socfpga:~# ./main.exe CL_PLATFORM_VENDOR: Altera Corporation CL_DEVICE_VERSION: OpenCL 1.0 Altera SDK for OpenCL, Version 14.0 CL_DRIVER_VERSION: 14.0 CL_DEVICE_OPENCL_C_VERSION: OpenCL C 1.0 CL_DEVICE_MAX_COMPUTE_UNITS: 1 CL_DEVICE_GLOBAL_MEM_SIZE: 1073741824 CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE: 0 CL_DEVICE_LOCAL_MEM_SIZE: 16384 CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE: 268435456 CL_DEVICE_MAX_CONSTANT_ARGS: 8 CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR: 4 CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR: 4 CL_DEVICE_ENDIAN_LITTLE: 1 --- Quote End --- So my question before is still outstanding. What directory do I include in my compilation step so it pulls in the correct "gl.h" file? Also, I could not find any of this information in the documentation. I apologize if it is there but I couldn't find it. If it isn't there, you may want to include it for other developers in the future.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
dan.j.williams, the Linux distribution that is on the SoC board does not have OpenGL installed. Also, the ARM cross-compiler tool chain that we ship does not have OpenGL support. That's why gl.h is not found. Of course, you probably don't care about OpenGL at all, only C++ OpenCL interface.
The best thing I can think of is to modify cl.hpp to not include gl.h (cl.hpp is created by the Khronos group and we do not modify it). Give it a quick try. I will try to do the same to see if I can get you through quickly. We did use cl.hpp on non-SoC platform and it works. So that's the only issue you should see with the C++ interface.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
OK, I fixed cl.hpp file to not include gl.h. We do not support OpenCL-OpenGL interoperability anyway, so there is no need to include that. Overwrite C:/altera/14.0/hld/host/include/CL/cl.hpp with attached cl.hpp.txt (make sure it's still called cl.hpp, I couldn't attach a file with .hpp extension).
I tested a simple program that includes cl.hpp and it failed as you described before the change and compiles with the change. You can also use a random gl.hpp that you found, as long as you don't actually use any of the GL-related functions. We'll fix this in the new release of the tool. Thanks a lot for letting us know!- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
dsk,
I followed your instructions of replacing the installed "cl.hpp" file with the one you posted here. I was able to compile, link, and run the sample code I have in this post successfully on the FPGA development board. Thank you. Here is the modified makefile for those interested.
all: main.exe
main.exe: main.o
arm-linux-gnueabihf-g++ -LC:\altera\14.0\hld\board\c5soc\arm32\lib -LC:/altera/14.0/hld/host/arm32/lib -lalteracl -lalterahalmmd -lalterammdpcie -lelf -lrt -lstdc++ -o main.exe main.o
main.o: main.cpp
arm-linux-gnueabihf-g++ -IC:/altera/14.0/hld/host/include -c main.cpp
clean:
rm main.o main.exe

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page