Skip to content

Commit

Permalink
Updated CUDA Name Clash Checker By Added CUDA-specific keywords (#60)
Browse files Browse the repository at this point in the history
This pull request addresses issue #59 by adding more CUDA-specific
keywords to enhance the checking of variable/function names and prevent
name clashes

---------

Co-authored-by: EmilyBourne <[email protected]>
Co-authored-by: bauom <[email protected]>
  • Loading branch information
3 people committed Nov 8, 2024
1 parent 4f11d53 commit 45c013e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file.

- #32 : Add support for `nvcc` Compiler and `cuda` language as a possible option.
- #48 : Fix incorrect handling of imports in `cuda`.
- #59 : Updated `cuda` clash checker.
- #42 : Add support for custom kernel in`cuda`.
- #42 : Add Cuda module to Pyccel. Add support for `cuda.synchronize` function.

Expand Down
36 changes: 35 additions & 1 deletion pyccel/naming/cudanameclashchecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class CudaNameClashChecker(LanguageNameClashChecker):
verify that they do not cause name clashes. Name clashes may be due to
new variables, or due to the use of reserved keywords.
"""

# Keywords as mentioned on https://en.cppreference.com/w/c/keyword
keywords = set(['isign', 'fsign', 'csign', 'auto', 'break', 'case', 'char', 'const',
'continue', 'default', 'do', 'double', 'else', 'enum',
Expand All @@ -37,7 +38,40 @@ class CudaNameClashChecker(LanguageNameClashChecker):
'GET_INDEX_FUNC_H2', 'GET_INDEX_FUNC', 'GET_INDEX',
'INDEX', 'GET_ELEMENT', 'free_array', 'free_pointer',
'get_index', 'numpy_to_ndarray_strides',
'numpy_to_ndarray_shape', 'get_size', 'order_f', 'order_c', 'array_copy_data'])
'numpy_to_ndarray_shape', 'get_size', 'order_f', 'order_c', 'array_copy_data'
'__global__', '__device__', '__host__','__constant__', '__shared__',
'__managed__','threadIdx', 'blockIdx', 'blockDim', 'gridDim',
'warpSize', 'cudaMalloc', 'cudaFree', 'cudaMemcpy', 'cudaMemset',
'cudaMallocHost', 'cudaFreeHost', 'cudaMallocPitch',
'cudaMallocArray', 'cudaFreeArray', 'cudaHostAlloc',
'cudaHostRegister', 'cudaHostUnregister', 'cudaHostGetDevicePointer',
'cudaHostGetFlags', 'cudaDeviceSynchronize', 'cudaDeviceReset',
'cudaSetDevice', 'cudaGetDeviceCount', 'cudaGetDeviceProperties',
'cudaChooseDevice', 'cudaSetDeviceFlags', 'cudaGetDevice',
'cudaStreamCreate', 'cudaStreamDestroy', 'cudaStreamSynchronize',
'cudaStreamWaitEvent', 'cudaEventCreate', 'cudaEventDestroy', 'cudaEventRecord',
'cudaEventSynchronize', 'cudaEventElapsedTime', 'cuInit', 'cuDeviceGet',
'cuDeviceGetCount', 'cuDeviceGetName',
'cuDeviceComputeCapability', 'cuCtxCreate', 'cuCtxDestroy',
'cuCtxSynchronize', 'cuModuleLoad', 'cuModuleUnload',
'cuModuleGetFunction', 'cuModuleGetGlobal', 'cuModuleGetTexRef',
'cuMemAlloc', 'cuMemFree', 'cuMemcpyHtoD', 'cuMemcpyDtoH',
'cuMemcpyDtoD', 'cuMemcpyHtoDAsync', 'cuMemcpyDtoHAsync',
'cuMemcpyDtoDAsync', 'cuMemsetD8', 'cuMemsetD16', 'cuMemsetD32',
'cuMemsetD2D8', 'cuMemsetD2D16', 'cuMemsetD2D32', 'cuParamSetSize',
'cuParamSeti', 'cuParamSetf', 'cuParamSetv', 'cuLaunch', 'cuLaunchGrid',
'cuLaunchGridAsync', 'cuEventCreate', 'cuEventRecord', 'cuEventQuery',
'cuEventSynchronize', 'cuEventDestroy', 'cuEventElapsedTime',
'cuStreamCreate', 'cuStreamQuery', 'cuStreamSynchronize',
'cuStreamDestroy', 'cuFuncSetBlockShape', 'cuFuncSetSharedSize',
'cuFuncGetAttribute', 'cuTexRefCreate', 'cuTexRefDestroy',
'cuTexRefSetArray', 'cuTexRefSetAddress', 'cuTexRefSetAddress2D',
'cuTexRefSetFormat', 'cuTexRefSetAddressMode', 'cuTexRefSetFilterMode',
'cuTexRefSetFlags', 'cuTexRefGetAddress', 'cuTexRefGetArray',
'cuTexRefGetAddressMode', 'cuTexRefGetFilterMode', 'cuTexRefGetFormat',
'cuTexRefGetFlags', 'cuLaunchKernel', 'cuOccupancyMaxActiveBlocksPerMultiprocessor',
'cuOccupancyMaxPotentialBlockSize', 'cuOccupancyMaxPotentialBlockSizeWithFlags'
])

def has_clash(self, name, symbols):
"""
Expand Down

0 comments on commit 45c013e

Please sign in to comment.