/* 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 #include #include #include #include "UnitTests.h" #include "RadixSortBenchmark.h" #include "LaunchOverheadBenchmark.h" #undef NUM_TESTS struct ConstBuffer { float4 m_a; float4 m_b; float4 m_c; }; int main() { if(0) { // radix sort test Device* deviceHost; Device* deviceGPU; { DeviceUtils::Config cfg; // Choose AMD or NVidia #ifdef CL_PLATFORM_AMD cfg.m_vendor = DeviceUtils::Config::VD_AMD; #endif #ifdef CL_PLATFORM_INTEL cfg.m_vendor = DeviceUtils::Config::VD_INTEL; #endif #ifdef CL_PLATFORM_NVIDIA cfg.m_vendor = adl::DeviceUtils::Config::VD_NV; #endif deviceGPU = DeviceUtils::allocate( TYPE_DX11, cfg ); deviceHost = DeviceUtils::allocate( TYPE_HOST, cfg ); } { int maxSize = 512*20; int size = maxSize; HostBuffer buf0( deviceHost, maxSize ); HostBuffer buf1( deviceHost, maxSize ); Buffer buf2( deviceGPU, maxSize ); RadixSort::Data* dataH = RadixSort::allocate( deviceHost, maxSize, RadixSortBase::SORT_STANDARD ); RadixSort::Data* dataC = RadixSort::allocate( deviceGPU, maxSize, RadixSortBase::SORT_ADVANCED ); { size = NEXTMULTIPLEOF( size, 512 ); for(int i=0; i::execute( dataH, buf0, size ); RadixSort::execute( dataC, buf2, size ); buf2.read( buf1.m_ptr, size ); DeviceUtils::waitForCompletion( deviceGPU ); for(int i=0; i::deallocate( dataH ); RadixSort::deallocate( dataC ); } DeviceUtils::deallocate( deviceHost ); DeviceUtils::deallocate( deviceGPU ); } if(0) { launchOverheadBenchmark(); } if(0) { radixSortBenchmark(); } if(0) { radixSortBenchmark(); } if(1) { runAllTest(); } printf("End, press \n"); getchar(); }