<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.haidhi.my.id/wiki/index.php?action=history&amp;feed=atom&amp;title=OpenCL%3A_Setup_%26_Hello_World</id>
	<title>OpenCL: Setup &amp; Hello World - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.haidhi.my.id/wiki/index.php?action=history&amp;feed=atom&amp;title=OpenCL%3A_Setup_%26_Hello_World"/>
	<link rel="alternate" type="text/html" href="https://wiki.haidhi.my.id/wiki/index.php?title=OpenCL:_Setup_%26_Hello_World&amp;action=history"/>
	<updated>2026-11-02T00:33:39Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://wiki.haidhi.my.id/wiki/index.php?title=OpenCL:_Setup_%26_Hello_World&amp;diff=524&amp;oldid=prev</id>
		<title>SanzSkuy at 08:29, 2 January 2026</title>
		<link rel="alternate" type="text/html" href="https://wiki.haidhi.my.id/wiki/index.php?title=OpenCL:_Setup_%26_Hello_World&amp;diff=524&amp;oldid=prev"/>
		<updated>2026-01-02T08:29:07Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 08:29, 2 January 2026&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l98&quot;&gt;Line 98:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 98:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;add_executable(main main.cpp)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;add_executable(main main.cpp)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;target_link_libraries(&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;opencl_hello &lt;/del&gt;OpenCL::OpenCL)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;target_link_libraries(&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;main &lt;/ins&gt;OpenCL::OpenCL)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Lalu cara run&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Lalu cara run&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>SanzSkuy</name></author>
	</entry>
	<entry>
		<id>https://wiki.haidhi.my.id/wiki/index.php?title=OpenCL:_Setup_%26_Hello_World&amp;diff=523&amp;oldid=prev</id>
		<title>SanzSkuy at 08:25, 2 January 2026</title>
		<link rel="alternate" type="text/html" href="https://wiki.haidhi.my.id/wiki/index.php?title=OpenCL:_Setup_%26_Hello_World&amp;diff=523&amp;oldid=prev"/>
		<updated>2026-01-02T08:25:50Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 08:25, 2 January 2026&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Install OpenCL (untuk Nvidia)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Install OpenCL (untuk Nvidia)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;syntaxhighligh &lt;/del&gt;lang=bash&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;syntaxhighlight &lt;/ins&gt;lang=bash&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;sudo pacman -S opencl-headers ocl-icd opencl-nvidia&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;sudo pacman -S opencl-headers ocl-icd opencl-nvidia&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>SanzSkuy</name></author>
	</entry>
	<entry>
		<id>https://wiki.haidhi.my.id/wiki/index.php?title=OpenCL:_Setup_%26_Hello_World&amp;diff=522&amp;oldid=prev</id>
		<title>SanzSkuy: Created page with &quot;Install OpenCL (untuk Nvidia) &lt;syntaxhighligh lang=bash&gt; sudo pacman -S opencl-headers ocl-icd opencl-nvidia &lt;/syntaxhighlight&gt; main.cpp &lt;syntaxhighlight lang=cpp&gt; #include &lt;CL/cl.h&gt; #include &lt;iostream&gt; #include &lt;vector&gt;  const char* kernelSource = R&quot;( __kernel void vector_add(__global const float* a,                          __global const float* b,                          __global float* c) {     int gid = get_global_id(0);     c[gid] = a[gid] + b[gid]; } )&quot;;  int mai...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.haidhi.my.id/wiki/index.php?title=OpenCL:_Setup_%26_Hello_World&amp;diff=522&amp;oldid=prev"/>
		<updated>2026-01-02T08:25:35Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;Install OpenCL (untuk Nvidia) &amp;lt;syntaxhighligh lang=bash&amp;gt; sudo pacman -S opencl-headers ocl-icd opencl-nvidia &amp;lt;/syntaxhighlight&amp;gt; main.cpp &amp;lt;syntaxhighlight lang=cpp&amp;gt; #include &amp;lt;CL/cl.h&amp;gt; #include &amp;lt;iostream&amp;gt; #include &amp;lt;vector&amp;gt;  const char* kernelSource = R&amp;quot;( __kernel void vector_add(__global const float* a,                          __global const float* b,                          __global float* c) {     int gid = get_global_id(0);     c[gid] = a[gid] + b[gid]; } )&amp;quot;;  int mai...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Install OpenCL (untuk Nvidia)&lt;br /&gt;
&amp;lt;syntaxhighligh lang=bash&amp;gt;&lt;br /&gt;
sudo pacman -S opencl-headers ocl-icd opencl-nvidia&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
main.cpp&lt;br /&gt;
&amp;lt;syntaxhighlight lang=cpp&amp;gt;&lt;br /&gt;
#include &amp;lt;CL/cl.h&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;vector&amp;gt;&lt;br /&gt;
&lt;br /&gt;
const char* kernelSource = R&amp;quot;(&lt;br /&gt;
__kernel void vector_add(__global const float* a,&lt;br /&gt;
                         __global const float* b,&lt;br /&gt;
                         __global float* c) {&lt;br /&gt;
    int gid = get_global_id(0);&lt;br /&gt;
    c[gid] = a[gid] + b[gid];&lt;br /&gt;
}&lt;br /&gt;
)&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
int main() {&lt;br /&gt;
    const int ARRAY_SIZE = 1024;&lt;br /&gt;
    &lt;br /&gt;
    // Host data&lt;br /&gt;
    std::vector&amp;lt;float&amp;gt; a(ARRAY_SIZE, 1.0f);&lt;br /&gt;
    std::vector&amp;lt;float&amp;gt; b(ARRAY_SIZE, 2.0f);&lt;br /&gt;
    std::vector&amp;lt;float&amp;gt; c(ARRAY_SIZE);&lt;br /&gt;
    &lt;br /&gt;
    // Get platform&lt;br /&gt;
    cl_platform_id platform;&lt;br /&gt;
    clGetPlatformIDs(1, &amp;amp;platform, nullptr);&lt;br /&gt;
    &lt;br /&gt;
    // Get device&lt;br /&gt;
    cl_device_id device;&lt;br /&gt;
    clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 1, &amp;amp;device, nullptr);&lt;br /&gt;
    &lt;br /&gt;
    // Create context&lt;br /&gt;
    cl_context context = clCreateContext(nullptr, 1, &amp;amp;device, nullptr, nullptr, nullptr);&lt;br /&gt;
    &lt;br /&gt;
    // Create command queue&lt;br /&gt;
    cl_command_queue queue = clCreateCommandQueue(context, device, 0, nullptr);&lt;br /&gt;
    &lt;br /&gt;
    // Create buffers&lt;br /&gt;
    cl_mem bufA = clCreateBuffer(context, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,&lt;br /&gt;
                                  sizeof(float) * ARRAY_SIZE, a.data(), nullptr);&lt;br /&gt;
    cl_mem bufB = clCreateBuffer(context, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,&lt;br /&gt;
                                  sizeof(float) * ARRAY_SIZE, b.data(), nullptr);&lt;br /&gt;
    cl_mem bufC = clCreateBuffer(context, CL_MEM_WRITE_ONLY,&lt;br /&gt;
                                  sizeof(float) * ARRAY_SIZE, nullptr, nullptr);&lt;br /&gt;
    &lt;br /&gt;
    // Create program&lt;br /&gt;
    cl_program program = clCreateProgramWithSource(context, 1, &amp;amp;kernelSource, nullptr, nullptr);&lt;br /&gt;
    clBuildProgram(program, 1, &amp;amp;device, nullptr, nullptr, nullptr);&lt;br /&gt;
    &lt;br /&gt;
    // Create kernel&lt;br /&gt;
    cl_kernel kernel = clCreateKernel(program, &amp;quot;vector_add&amp;quot;, nullptr);&lt;br /&gt;
    &lt;br /&gt;
    // Set arguments&lt;br /&gt;
    clSetKernelArg(kernel, 0, sizeof(cl_mem), &amp;amp;bufA);&lt;br /&gt;
    clSetKernelArg(kernel, 1, sizeof(cl_mem), &amp;amp;bufB);&lt;br /&gt;
    clSetKernelArg(kernel, 2, sizeof(cl_mem), &amp;amp;bufC);&lt;br /&gt;
    &lt;br /&gt;
    // Execute kernel&lt;br /&gt;
    size_t globalSize = ARRAY_SIZE;&lt;br /&gt;
    clEnqueueNDRangeKernel(queue, kernel, 1, nullptr, &amp;amp;globalSize, nullptr, 0, nullptr, nullptr);&lt;br /&gt;
    &lt;br /&gt;
    // Read results&lt;br /&gt;
    clEnqueueReadBuffer(queue, bufC, CL_TRUE, 0, sizeof(float) * ARRAY_SIZE, c.data(), 0, nullptr, nullptr);&lt;br /&gt;
    &lt;br /&gt;
    // Verify results&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;OpenCL Hello World - Vector Addition\n&amp;quot;;&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;First 5 results: &amp;quot;;&lt;br /&gt;
    for (int i = 0; i &amp;lt; 5; i++) {&lt;br /&gt;
        std::cout &amp;lt;&amp;lt; c[i] &amp;lt;&amp;lt; &amp;quot; &amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;\nExpected: 3.0 for all elements\n&amp;quot;;&lt;br /&gt;
    &lt;br /&gt;
    // Cleanup&lt;br /&gt;
    clReleaseMemObject(bufA);&lt;br /&gt;
    clReleaseMemObject(bufB);&lt;br /&gt;
    clReleaseMemObject(bufC);&lt;br /&gt;
    clReleaseKernel(kernel);&lt;br /&gt;
    clReleaseProgram(program);&lt;br /&gt;
    clReleaseCommandQueue(queue);&lt;br /&gt;
    clReleaseContext(context);&lt;br /&gt;
    &lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
CMakeLists.txt&lt;br /&gt;
&amp;lt;syntaxhighlight lang=cmake&amp;gt;&lt;br /&gt;
cmake_minimum_required(VERSION 3.16)&lt;br /&gt;
project(opencl_hello C CXX)&lt;br /&gt;
&lt;br /&gt;
set(CMAKE_C_STANDARD 11)&lt;br /&gt;
&lt;br /&gt;
find_package(OpenCL REQUIRED)&lt;br /&gt;
&lt;br /&gt;
add_executable(main main.cpp)&lt;br /&gt;
&lt;br /&gt;
target_link_libraries(opencl_hello OpenCL::OpenCL)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Lalu cara run&lt;br /&gt;
&amp;lt;syntaxhighlight lang=bash&amp;gt;&lt;br /&gt;
mkdir build &amp;amp;&amp;amp; cd build&lt;br /&gt;
cmake ..&lt;br /&gt;
make&lt;br /&gt;
./main&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>SanzSkuy</name></author>
	</entry>
</feed>