/* Copyright (c) 2012 Advanced Micro Devices, Inc. This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 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. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ //Originally written by Takahiro Harada typedef unsigned int u32; #define GET_GROUP_IDX get_group_id(0) #define GET_LOCAL_IDX get_local_id(0) #define GET_GLOBAL_IDX get_global_id(0) #define GET_GROUP_SIZE get_local_size(0) #define GROUP_LDS_BARRIER barrier(CLK_LOCAL_MEM_FENCE) // takahiro end #define WG_SIZE 128 #define m_numElems x #define m_numBlocks y #define m_numScanBlocks z /*typedef struct { uint m_numElems; uint m_numBlocks; uint m_numScanBlocks; uint m_padding[1]; } ConstBuffer; */ float4 ScanExclusiveFloat4(__local float4* data, u32 n, int lIdx, int lSize) { float4 blocksum; int offset = 1; for(int nActive=n>>1; nActive>0; nActive>>=1, offset<<=1) { GROUP_LDS_BARRIER; for(int iIdx=lIdx; iIdx>= 1; for(int nActive=1; nActive>=1 ) { GROUP_LDS_BARRIER; for( int iIdx = lIdx; iIdx