gpu_area.cppGo to the documentation of this file.00001 /* 00002 Copyright (c) 2010, Paul Furgale and Chi Hay Tong 00003 All rights reserved. 00004 00005 Redistribution and use in source and binary forms, with or without 00006 modification, are permitted provided that the following conditions are 00007 met: 00008 00009 * Redistributions of source code must retain the above copyright notice, 00010 this list of conditions and the following disclaimer. 00011 * Redistributions in binary form must reproduce the above copyright 00012 notice, this list of conditions and the following disclaimer in the 00013 documentation and/or other materials provided with the distribution. 00014 * The names of its contributors may not be used to endorse or promote 00015 products derived from this software without specific prior written 00016 permission. 00017 00018 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00019 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 00020 TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 00021 PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 00022 OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00023 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00024 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00025 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00026 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00027 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00028 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00029 */ 00030 00042 #include "gpu_area.h" 00043 #include "CudaSynchronizedMemory.hpp" 00044 00045 00046 00047 namespace asrl { 00048 00049 00050 // unbind a texture from an array 00051 void fh_untexturizeIntegral() 00052 { 00053 cudaError_t err = fh_untexturizeIntegral_c(); 00054 ASRL_ASSERT_EQ(err,cudaSuccess, "Unable to unbind the integral image texture. " << cudaGetErrorString(err)); 00055 return; 00056 } 00057 00058 // Bind the cudaArray integral image to a texture 00059 void texturize_integral_image(cudaArray* intImg) 00060 { 00061 cudaError_t err = texturize_integral_image_c(intImg); 00062 ASRL_ASSERT_EQ(err,cudaSuccess, "Unable to bind the integral image texture. " << cudaGetErrorString(err)); 00063 return; 00064 } 00065 00066 00067 float iiAreaLookupC(cudaArray * image, float cx, float cy, float width, float height) 00068 { 00069 texturize_integral_image(image); 00070 00071 dim3 threads; // 512 threads 00072 00073 threads.x = 1;//FH_X_THREADS; 00074 threads.y = 1;//FH_Y_THREADS; 00075 threads.z = 1; 00076 dim3 grid; 00077 grid.x = 1; 00078 grid.y = 1; 00079 grid.z = 1; 00080 00081 CudaSynchronizedMemory<float> result; 00082 result.init(1); 00083 00084 run_iiAreaLookupCDKernel(grid, threads, result.d_get(), cx, cy, width,height); 00085 ASRL_CHECK_CUDA_ERROR_DBG("iiAreaLookupCDKernel"); 00086 00087 result.pullFromDevice(); 00088 00089 fh_untexturizeIntegral(); 00090 00091 return result[0]; 00092 } 00093 00094 } Generated on Fri Apr 30 20:06:19 2010 for gpusurf by 1.6.2 |