patch 9.1.0906: filetype: Nvidia PTX files are not recognized

Problem:  filetype: Nvidia PTX files are not recognized
Solution: detect '*.ptx' files as ptx filetype (Yinzuo Jiang)

Reference: https://docs.nvidia.com/cuda/parallel-thread-execution/

closes: #16171

Signed-off-by: Yinzuo Jiang <jiangyinzuo@foxmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Yinzuo Jiang
2024-12-05 21:31:09 +01:00
committed by Christian Brabandt
parent 73785accfd
commit bdb5f85a51
6 changed files with 77 additions and 0 deletions

2
.github/MAINTAINERS vendored
View File

@ -249,6 +249,7 @@ runtime/ftplugin/postscr.vim @mrdubya
runtime/ftplugin/prisma.vim @ribru17
runtime/ftplugin/ps1.vim @heaths
runtime/ftplugin/ps1xml.vim @heaths
runtime/ftplugin/ptx.vim @jiangyinzuo
runtime/ftplugin/purescript.vim @ribru17
runtime/ftplugin/pymanifest.vim @ObserverOfTime
runtime/ftplugin/python.vim @tpict
@ -556,6 +557,7 @@ runtime/syntax/prolog.vim @XVilka
runtime/syntax/ps1.vim @heaths
runtime/syntax/ps1xml.vim @heaths
runtime/syntax/psl.vim @danielkho
runtime/syntax/ptx.vim @jiangyinzuo
runtime/syntax/pymanifest.vim @ObserverOfTime
runtime/syntax/qb64.vim @dkearns
runtime/syntax/qml.vim @ChaseKnowlden

View File

@ -1976,6 +1976,10 @@ au BufNewFile,BufRead *.pk setf poke
" Protocols
au BufNewFile,BufRead */etc/protocols setf protocols
" Nvidia PTX (Parallel Thread Execution)
" See https://docs.nvidia.com/cuda/parallel-thread-execution/
au BufNewFile,BufRead *.ptx setf ptx
" Purescript
au BufNewFile,BufRead *.purs setf purescript

16
runtime/ftplugin/ptx.vim Normal file
View File

@ -0,0 +1,16 @@
" Vim filetype plugin file
" Language: Nvidia PTX (Parellel Thread Execution)
" Maintainer: Yinzuo Jiang <jiangyinzuo@foxmail.com>
" Last Change: 2024-12-05
if exists("b:did_ftplugin")
finish
endif
let b:did_ftplugin = 1
" Comments in PTX follow C/C++ syntax
" See: https://docs.nvidia.com/cuda/parallel-thread-execution/#syntax
setlocal commentstring=//\ %s
let b:undo_ftplugin = 'setl commentstring<'

52
runtime/syntax/ptx.vim Normal file
View File

@ -0,0 +1,52 @@
" Vim syntax file
" Language: Nvidia PTX (Parallel Thread Execution)
" Maintainer: Yinzuo Jiang <jiangyinzuo@foxmail.com>
" Latest Revision: 2024-12-05
if exists("b:current_syntax")
finish
endif
let s:cpo_save = &cpo
set cpo&vim
syntax iskeyword .,_,a-z,48-57
" https://docs.nvidia.com/cuda/parallel-thread-execution/#directives
syntax keyword ptxFunction .entry .func
syntax keyword ptxDirective .branchtargets .file .loc .secion .maxnctapersm .maxnreg .minnctapersm .noreturn .pragma .reqntid .target .version .weak
syntax keyword ptxOperator .address_size .alias .align .callprototype .calltargets
syntax keyword ptxStorageClass .common .const .extern .global .local .param .reg .sreg .shared .tex .visible
syntax keyword ptxType .explicitcluster .maxclusterrank .reqnctapercluster
" https://docs.nvidia.com/cuda/parallel-thread-execution/#fundamental-types
" signed integer
syntax keyword ptxType .s8 .s16 .s32 .s64
" unsigned integer
syntax keyword ptxType .u8 .u16 .u32 .u64
" floating-point
syntax keyword ptxType .f16 .f16x2 .f32 .f64
" bits (untyped)
syntax keyword ptxType .b8 .b16 .b32 .b64 .b128
" predicate
syntax keyword ptxType .pred
" https://docs.nvidia.com/cuda/parallel-thread-execution/#instruction-statements
syntax keyword ptxStatement ret
syntax region ptxCommentL start="//" skip="\\$" end="$" keepend
syntax region ptxComment matchgroup=ptxCommentStart start="/\*" end="\*/" extend
hi def link ptxFunction Function
hi def link ptxDirective Keyword
hi def link ptxOperator Operator
hi def link ptxStorageClass StorageClass
hi def link ptxType Type
hi def link ptxStatement Statement
hi def link ptxCommentL ptxComment
hi def link ptxCommentStart ptxComment
hi def link ptxComment Comment
let &cpo = s:cpo_save
unlet s:cpo_save

View File

@ -608,6 +608,7 @@ def s:GetFilenameChecks(): dict<list<string>>
ps1xml: ['file.ps1xml'],
psf: ['file.psf'],
psl: ['file.psl'],
ptx: ['file.ptx'],
pug: ['file.pug'],
puppet: ['file.pp'],
purescript: ['file.purs'],

View File

@ -704,6 +704,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
906,
/**/
905,
/**/