- Hands-On GPU:Accelerated Computer Vision with OpenCV and CUDA
- Bhaumik Vaidya
- 158字
- 2021-08-13 15:48:21
Passing parameters by value
If you recall, in the gpuAdd program, the syntax for calling the kernel was as follows:
gpuAdd << <1,1> >>(1,4,d_c)
On the other hand, the signature of the gpuAdd function in definition was as follows:
__global__ gpuAdd(int d_a, int d_b, int *d_c)
So, you can see that we are passing values of d_a and d_b while calling the kernel. First, parameter 1 will be copied to d_a and then parameter 4 will be copied to d_b while calling the kernal. The answer after addition will be stored at the address pointed by d_c on device memory. Instead of directly passing values 1 and 4 as inputs to the kernel, we can also write the following:
gpuAdd << <1,1> >>(a,b,d_c)
Here, a and b are integer variables that can contain any integer values. Passing parameters by values is not recommended, as it creates unnecessary confusion and complications in programs. It is better to pass parameters by reference.
- Unity 2020 By Example
- 樂高機器人設計技巧:EV3結構設計與編程指導
- Java:Data Science Made Easy
- Android Native Development Kit Cookbook
- H5頁面設計:Mugeda版(微課版)
- Java 9 Programming By Example
- Python+Office:輕松實現Python辦公自動化
- 視窗軟件設計和開發自動化:可視化D++語言
- TypeScript圖形渲染實戰:2D架構設計與實現
- Xamarin Cross-Platform Development Cookbook
- Laravel Design Patterns and Best Practices
- JavaWeb從入門到精通(視頻實戰版)
- Software Architecture with Python
- PHP程序設計經典300例
- ServiceDesk Plus 8.x Essentials