This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # run multiply function on GPU | |
| multiply_func( | |
| result_gpu, a_gpu, b_gpu, | |
| block=(100, 1, 1), | |
| grid=(1, 1, 1) | |
| ) | |
| # Get data back from GPU | |
| cuda.memcpy_dtoh(result, result_gpu) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Check if PyCuda is installed | |
| package_name = 'pycuda' | |
| use_cuda = importlib.util.find_spec(package_name) is not None | |
| if use_cuda: | |
| import pycuda.driver as cuda | |
| import pycuda.autoinit | |
| from pycuda.compiler import SourceModule |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #define IMW __IMW_keyword__ // image width (px) | |
| #define IMH __IMH_keyword__ // image height (px) | |
| #define BX __BX_keyword__ // block index x | |
| #define BY __BY_keyword__ // block index y | |
| #define nTPB (BX*BY) // threads per block | |
| #define IMN 21 // buffer length |
OlderNewer