btGpuUtilsSharedCode.h

Go to the documentation of this file.
00001 /*
00002 Bullet Continuous Collision Detection and Physics Library, http://bulletphysics.org
00003 Copyright (C) 2006, 2009 Sony Computer Entertainment Inc. 
00004 
00005 This software is provided 'as-is', without any express or implied warranty.
00006 In no event will the authors be held liable for any damages arising from the use of this software.
00007 Permission is granted to anyone to use this software for any purpose, 
00008 including commercial applications, and to alter it and redistribute it freely, 
00009 subject to the following restrictions:
00010 
00011 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.
00012 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
00013 3. This notice may not be removed or altered from any source distribution.
00014 */
00015 
00016 //----------------------------------------------------------------------------------------
00017 
00018 // Shared code for GPU-based utilities
00019 
00021 //  Keep this file free from Bullet headers
00022 //  will be compiled by both CPU and CUDA compilers
00023 //      file with definitions of BT_GPU_xxx should be included first
00025 
00026 //----------------------------------------------------------------------------------------
00027 
00028 #include "btGpuUtilsSharedDefs.h"
00029 
00030 //----------------------------------------------------------------------------------------
00031 
00032 extern "C"
00033 {
00034 
00035 //----------------------------------------------------------------------------------------
00036 
00037 //Round a / b to nearest higher integer value
00038 int BT_GPU_PREF(iDivUp)(int a, int b)
00039 {
00040     return (a % b != 0) ? (a / b + 1) : (a / b);
00041 } // iDivUp()
00042 
00043 //----------------------------------------------------------------------------------------
00044 
00045 // compute grid and thread block size for a given number of elements
00046 void BT_GPU_PREF(computeGridSize)(int n, int blockSize, int &numBlocks, int &numThreads)
00047 {
00048     numThreads = BT_GPU_min(blockSize, n);
00049     numBlocks = BT_GPU_PREF(iDivUp)(n, numThreads);
00050 } // computeGridSize()
00051 
00052 //----------------------------------------------------------------------------------------
00053 
00054 } // extern "C"
00055