question: private boolean test_float_1D ( ) { CUarray array = new CUarray ( ) ; CUDA_ARRAY_DESCRIPTOR ad = new CUDA_ARRAY_DESCRIPTOR ( ) ; ad . Format = CU_AD_FORMAT_FLOAT ; ad . Width = sizeX ; ad . Height = 1 ; ad . NumChannels = 1 ; cuArrayCreate ( array , ad ) ; Pointer pInput = Pointer . to ( input_float_1D ) ; cuMemcpyHtoA ( array , 0 , pInput , sizeX * Sizeof . FLOAT ) ; CUtexref texref = new CUtexref ( ) ; cuModuleGetTexRef ( texref , module , "texture_float_1D" ) ; cuTexRefSetFilterMode ( texref , CU_TR_FILTER_MODE_LINEAR ) ; cuTexRefSetAddressMode ( texref , 0 , CU_TR_ADDRESS_MODE_CLAMP ) ; cuTexRefSetFlags ( texref , CU_TRSF_NORMALIZED_COORDINATES ) ; cuTexRefSetFormat ( texref , CU_AD_FORMAT_FLOAT , 1 ) ; cuTexRefSetArray ( texref , array , CU_TRSA_OVERRIDE_FORMAT ) ; CUdeviceptr dOutput = new CUdeviceptr ( ) ; cuMemAlloc ( dOutput , Sizeof . FLOAT * 1 ) ; CUfunction function = new CUfunction ( ) ; cuModuleGetFunction ( function , module , "test_float_1D" ) ; Pointer kernelParameters = Pointer . to ( Pointer . to ( dOutput ) , Pointer . to ( new float [ ] { posX } ) ) ; cuLaunchKernel ( function , 1 , 1 , 1 , 1 , 1 , 1 , 0 , null , kernelParameters , null ) ; cuCtxSynchronize ( ) ; float hOutput [ ] = new float [ 1 ] ; cuMemcpyDtoH ( Pointer . to ( hOutput ) , dOutput , Sizeof . FLOAT * 1 ) ; log ( "Result float  1D " + Arrays . toString ( hOutput ) ) ; float expected [ ] = new float [ ] { 0.5f } ; boolean passed = Arrays . equals ( hOutput , expected ) ; log ( "Test   float  1D " + ( passed ? "PASSED" : "FAILED" ) ) ; cuArrayDestroy ( array ) ; cuMemFree ( dOutput ) ; return passed ; }
target:  Test the 1D float texture access