Hi Enrique,
> First, I only want to compile a project and execute it to see how it works, specifically this one:
https://github.com/rsnemmen/OpenCL-examples/tree/master/add_numbers
As I can see, it has a Makefile which you could use. Anyway, on Linux you need to do something like:
clang -std=c99 add_numbers.c -lOpenCL -I/path/to/folder/with/CL/cl.h
Usually, libOpenCL.so and CL/cl.h are provided by OpenCL SDKs from HW/SW vendor, for example: [1], [2], [3], [4] and others [5]
But, you can also get them from KhronosGroup repos: OpenCL-ICD-Loader [6], OpenCL-Headers [7]
> I want to do that the .c file uses the .cl that i have compiled before with clang and i do not know how to do it.
This is an interesting question. Basically, in OpenCL you can build your device program in a separate ways:
Summarizing:
If you want to optimize your OpenCL code by yourself you can do the following:
Personally, I would go with the last option.
[1]: https://software.intel.com/en-us/opencl-sdk
[2]: https://developer.nvidia.com/opencl
[3]: https://github.com/GPUOpen-LibrariesAndSDKs/OCL-SDK/releases
[4]: https://developer.arm.com/solutions/graphics/apis/opencl
[5]: https://www.iwocl.org/resources/opencl-implementations/
--------------------------------------------------------------------
Joint Stock Company Intel A/O
Registered legal address: Krylatsky Hills Business Park,
17 Krylatskaya Str., Bldg 4, Moscow 121614,
Russian Federation
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
Hi Enrique,
> 1) What do yourefer by OpenCL RT?
I mean OpenCL Runtime – some library which implements OpenCL API for you.
Basically, OpenCL consist of two parts: host code and device code.
Host code can be written at any language and actually it is a regular C/C++/Python/whatever application which uses OpenCL API.
OpenCL API allows you to select platform, device, create context and buffers for data, create and build program for your device, create command queue and kernel, set kernel arguments and then enqueue your kernel for execution on the selected device.
You can always read the spec [1] to understand all these concepts. I would recommend section 3 “The OpenCL Architecture”: in particular, section 3.1 “Platform Model” and 3.2 “Execution Model”.
Also you can find some videos [2], slides [3] or articles [4] about this topic.
So, the next part is device code: it can be written on OpenCL C, C++ for OpenCL in clang, or any other language which can be represented in SPIR-V.
As I said in previous emails, device code can be compiled online or offline and then it will be launched on selected device using API.
I encourage you to read the spec or search for videos/slides/articles on this topic to get familiar with main OpenCL concepts/architecture/ideas.
> 2) Could you give me some examples of an open-source OpenCL implementation and update optimization pipeline?
Sure, here you go (there might be more implementations, I’m just not aware of them):
Please note that each implementation targets specific device or set of devices from one or more particular vendors.
The most generic/portable one is POCL, I guess.
[1]: https://www.khronos.org/registry/OpenCL/specs/2.2/pdf/OpenCL_API.pdf
[2]: https://www.youtube.com/watch?v=hUiX8rBcNzw
[4]: https://www.sciencedirect.com/topics/computer-science/opencl
[5]: https://github.com/pocl/pocl
[6]: https://github.com/intel/compute-runtime
[7]: https://github.com/intel/intel-graphics-compiler
[8]: https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime
[9]: https://github.com/RadeonOpenCompute/llvm
Hi Enrique,
I’m afraid I’m not very familiar with POCL and its details.
+ Pekka here, who is the main POCL maintainer (if I understand correctly) and I guess he can help you there better than me.
From: Enrique González <enrike.go...@gmail.com>
Sent: Sunday, September 29, 2019 7:51 PM
To: Sachkov, Alexey <alexey....@intel.com>
Subject: Re: [llvm-dev] Execute OpenCL
Hi Alexey,
Many thanks for your grateful replies, you are helping me a lot with all this information about my problem!
I am looking the documentation about OpenCL for understanding it better, the YouTube video was also very helpful.
During this days, I have tried to install SPIR-V target for making the hybrid compilation and prove how it could be optimized. Also I installed POCL (and an old LLVM version, so it requires one between 4.0 and 8.0). I have read the documentation at their page and it does not seems to say anything about how you can use this tool for optimize code, my boss neither has find anything, and we are looking for some site where we can learn how to use it and which flags we can prove for diferente results, because POCL looks like the tool we need for OpenCL pipeline optimizations.
Could you help us with this problem too? We are a little bit lost about this and if we solve this problem, I can begin the project we have in mind to help the community.
Thanks in advance.
Hi Enrique,
> I have been trying to use clang with the spir64 target (soir64-unknown-unknown) and the tool does not detect this target, i do not know why.
It is hard to say anything without additional information. Please provide command you are trying to launch
> I also tried to build also SPIRV-LLVM-Translator project[2] and it fails when making the project. It does not encounter the Polly library and fails.
Again, it is hard to help without any additional information or logs