2 Copyright (c) 2012 Advanced Micro Devices, Inc.
4 This software is provided 'as-is', without any express or implied warranty.
5 In no event will the authors be held liable for any damages arising from the use of this software.
6 Permission is granted to anyone to use this software for any purpose,
7 including commercial applications, and to alter it and redistribute it freely,
8 subject to the following restrictions:
10 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
11 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
12 3. This notice may not be removed or altered from any source distribution.
14 //Originally written by Takahiro Harada
16 #pragma OPENCL EXTENSION cl_amd_printf : enable
17 #pragma OPENCL EXTENSION cl_khr_local_int32_base_atomics : enable
19 typedef unsigned int u32;
20 #define GET_GROUP_IDX get_group_id(0)
21 #define GET_LOCAL_IDX get_local_id(0)
22 #define GET_GLOBAL_IDX get_global_id(0)
23 #define GET_GROUP_SIZE get_local_size(0)
24 #define GROUP_LDS_BARRIER barrier(CLK_LOCAL_MEM_FENCE)
25 #define GROUP_MEM_FENCE mem_fence(CLK_LOCAL_MEM_FENCE)
26 #define AtomInc(x) atom_inc(&(x))
27 #define AtomInc1(x, out) out = atom_inc(&(x))
29 #define make_uint4 (uint4)
30 #define make_uint2 (uint2)
31 #define make_int2 (int2)
42 __attribute__((reqd_work_group_size(64,1,1)))
43 void Copy1F4Kernel(__global float4* dst, __global float4* src,
46 int gIdx = GET_GLOBAL_IDX;
50 float4 a0 = src[gIdx];
57 __attribute__((reqd_work_group_size(64,1,1)))
58 void Copy2F4Kernel(__global float4* dst, __global float4* src,
61 int gIdx = GET_GLOBAL_IDX;
63 if( 2*gIdx <= cb.m_n )
65 float4 a0 = src[gIdx*2+0];
66 float4 a1 = src[gIdx*2+1];
74 __attribute__((reqd_work_group_size(64,1,1)))
75 void Copy4F4Kernel(__global float4* dst, __global float4* src,
78 int gIdx = GET_GLOBAL_IDX;
80 if( 4*gIdx <= cb.m_n )
87 float4 a0 = src[idx0];
88 float4 a1 = src[idx1];
89 float4 a2 = src[idx2];
90 float4 a3 = src[idx3];
100 __attribute__((reqd_work_group_size(64,1,1)))
101 void CopyF1Kernel(__global float* dstF1, __global float* srcF1,
104 int gIdx = GET_GLOBAL_IDX;
108 float a0 = srcF1[gIdx];
115 __attribute__((reqd_work_group_size(64,1,1)))
116 void CopyF2Kernel(__global float2* dstF2, __global float2* srcF2,
119 int gIdx = GET_GLOBAL_IDX;
123 float2 a0 = srcF2[gIdx];