2023-10-03 11:14:36 +08:00
( function ( Prism ) {
/* OpenCL kernel language */
Prism . languages . opencl = Prism . languages . extend ( 'c' , {
// Extracted from the official specs (2.0) and http://streamcomputing.eu/downloads/?opencl.lang (opencl-keywords, opencl-types) and http://sourceforge.net/tracker/?func=detail&aid=2957794&group_id=95717&atid=612384 (Words2, partly Words3)
'keyword' : /\b(?:(?:__)?(?:constant|global|kernel|local|private|read_only|read_write|write_only)|__attribute__|auto|(?:bool|u?(?:char|int|long|short)|half|quad)(?:2|3|4|8|16)?|break|case|complex|const|continue|(?:double|float)(?:16(?:x(?:1|2|4|8|16))?|1x(?:1|2|4|8|16)|2(?:x(?:1|2|4|8|16))?|3|4(?:x(?:1|2|4|8|16))?|8(?:x(?:1|2|4|8|16))?)?|default|do|else|enum|extern|for|goto|if|imaginary|inline|packed|pipe|register|restrict|return|signed|sizeof|static|struct|switch|typedef|uniform|union|unsigned|void|volatile|while)\b/ ,
// Extracted from http://streamcomputing.eu/downloads/?opencl.lang (opencl-const)
// Math Constants: https://www.khronos.org/registry/OpenCL/sdk/2.1/docs/man/xhtml/mathConstants.html
// Macros and Limits: https://www.khronos.org/registry/OpenCL/sdk/2.1/docs/man/xhtml/macroLimits.html
'number' : /(?:\b0x(?:[\da-f]+(?:\.[\da-f]*)?|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)[fuhl]{0,4}/i ,
'boolean' : /\b(?:false|true)\b/ ,
'constant-opencl-kernel' : {
pattern : /\b(?:CHAR_(?:BIT|MAX|MIN)|CLK_(?:ADDRESS_(?:CLAMP(?:_TO_EDGE)?|NONE|REPEAT)|FILTER_(?:LINEAR|NEAREST)|(?:GLOBAL|LOCAL)_MEM_FENCE|NORMALIZED_COORDS_(?:FALSE|TRUE))|CL_(?:BGRA|(?:HALF_)?FLOAT|INTENSITY|LUMINANCE|A?R?G?B?[Ax]?|(?:(?:UN)?SIGNED|[US]NORM)_(?:INT(?:8|16|32))|UNORM_(?:INT_101010|SHORT_(?:555|565)))|(?:DBL|FLT|HALF)_(?:DIG|EPSILON|(?:MAX|MIN)(?:(?:_10)?_EXP)?|MANT_DIG)|FLT_RADIX|HUGE_VALF?|(?:INT|LONG|SCHAR|SHRT)_(?:MAX|MIN)|INFINITY|MAXFLOAT|M_(?:[12]_PI|2_SQRTPI|E|LN(?:2|10)|LOG(?:2|10)E?|PI(?:_[24])?|SQRT(?:1_2|2))(?:_F|_H)?|NAN|(?:UCHAR|UINT|ULONG|USHRT)_MAX)\b/ ,
alias : 'constant'
}
} ) ;
Prism . languages . insertBefore ( 'opencl' , 'class-name' , {
// https://www.khronos.org/registry/OpenCL/sdk/2.1/docs/man/xhtml/scalarDataTypes.html
// https://www.khronos.org/registry/OpenCL/sdk/2.1/docs/man/xhtml/otherDataTypes.html
'builtin-type' : {
pattern : /\b(?:_cl_(?:command_queue|context|device_id|event|kernel|mem|platform_id|program|sampler)|cl_(?:image_format|mem_fence_flags)|clk_event_t|event_t|image(?:1d_(?:array_|buffer_)?t|2d_(?:array_(?:depth_|msaa_depth_|msaa_)?|depth_|msaa_depth_|msaa_)?t|3d_t)|intptr_t|ndrange_t|ptrdiff_t|queue_t|reserve_id_t|sampler_t|size_t|uintptr_t)\b/ ,
alias : 'keyword'
}
} ) ;
var attributes = {
// Extracted from http://streamcomputing.eu/downloads/?opencl_host.lang (opencl-types and opencl-host)
'type-opencl-host' : {
pattern : /\b(?:cl_(?:GLenum|GLint|GLuin|addressing_mode|bitfield|bool|buffer_create_type|build_status|channel_(?:order|type)|(?:u?(?:char|int|long|short)|double|float)(?:2|3|4|8|16)?|command_(?:queue(?:_info|_properties)?|type)|context(?:_info|_properties)?|device_(?:exec_capabilities|fp_config|id|info|local_mem_type|mem_cache_type|type)|(?:event|sampler)(?:_info)?|filter_mode|half|image_info|kernel(?:_info|_work_group_info)?|map_flags|mem(?:_flags|_info|_object_type)?|platform_(?:id|info)|profiling_info|program(?:_build_info|_info)?))\b/ ,
alias : 'keyword'
} ,
'boolean-opencl-host' : {
pattern : /\bCL_(?:FALSE|TRUE)\b/ ,
alias : 'boolean'
} ,
// Extracted from cl.h (2.0) and http://streamcomputing.eu/downloads/?opencl_host.lang (opencl-const)
'constant-opencl-host' : {
pattern : / \ b C L _ ( ? : A | A B G R | A D D R E S S _ ( ? : C L A M P ( ? : _ T O _ E D G E ) ? | M I R R O R E D _ R E P E A T | N O N E | R E P E A T ) | A R G B | B G R A | B L O C K I N G | B U F F E R _ C R E A T E _ T Y P E _ R E G I O N | B U I L D _ ( ? : E R R O R | I N _ P R O G R E S S | N O N E | P R O G R A M _ F A I L U R E | S U C C E S S ) | C O M M A N D _ ( ? : A C Q U I R E _ G L _ O B J E C T S | B A R R I E R | C O P Y _ ( ? : B U F F E R ( ? : _ R E C T | _ T O _ I M A G E ) ? | I M A G E ( ? : _ T O _ B U F F E R ) ? ) | F I L L _ ( ? : B U F F E R | I M A G E ) | M A P ( ? : _ B U F F E R | _ I M A G E ) | M A R K E R | M I G R A T E ( ? : _ S V M ) ? _ M E M _ O B J E C T S | N A T I V E _ K E R N E L | N D R A N G E _ K E R N E L | R E A D _ ( ? : B U F F E R ( ? : _ R E C T ) ? | I M A G E ) | R E L E A S E _ G L _ O B J E C T S | S V M _ ( ? : F R E E | M A P | M E M C P Y | M E M F I L L | U N M A P ) | T A S K | U N M A P _ M E M _ O B J E C T | U S E R | W R I T E _ ( ? : B U F F E R ( ? : _ R E C T ) ? | I M A G E ) ) | C O M P I L E R _ N O T _ A V A I L A B L E | C O M P I L E _ P R O G R A M _ F A I L U R E | C O M P L E T E | C O N T E X T _ ( ? : D E V I C E S | I N T E R O P _ U S E R _ S Y N C | N U M _ D E V I C E S | P L A T F O R M | P R O P E R T I E S | R E F E R E N C E _ C O U N T ) | D E P T H ( ? : _ S T E N C I L ) ? | D E V I C E _ ( ? : A D D R E S S _ B I T S | A F F I N I T Y _ D O M A I N _ ( ? : L [ 1 - 4 ] _ C A C H E | N E X T _ P A R T I T I O N A B L E | N U M A ) | A V A I L A B L E | B U I L T _ I N _ K E R N E L S | C O M P I L E R _ A V A I L A B L E | D O U B L E _ F P _ C O N F I G | E N D I A N _ L I T T L E | E R R O R _ C O R R E C T I O N _ S U P P O R T | E X E C U T I O N _ C A P A B I L I T I E S | E X T E N S I O N S | G L O B A L _ ( ? : M E M _ ( ? : C A C H E L I N E _ S I Z E | C A C H E _ S I Z E | C A C H E _ T Y P E | S I Z E ) | V A R I A B L E _ P R E F E R R E D _ T O T A L _ S I Z E ) | H O S T _ U N I F I E D _ M E M O R Y | I L _ V E R S I O N | I M A G E ( ? : 2 D _ M A X _ ( ? : H E I G H T | W I D T H ) | 3 D _ M A X _ ( ? : D E P T H | H E I G H T | W I D T H ) | _ B A S E _ A D D R E S S _ A L I G N M E N T | _ M A X _ A R R A Y _ S I Z E | _ M A X _ B U F F E R _ S I Z E | _ P I T C H _ A L I G N M E N T | _ S U P P O R T ) | L I N K E R _ A V A I L A B L E | L O C A L _ M E M _ S I Z E | L O C A L _ M E M _ T Y P E | M A X _ ( ? : C L O C K _ F R E Q U E N C Y | C O M P U T E _ U N I T S | C O N S T A N T _ A R G S | C O N S T A N T _ B U F F E R _ S I Z E | G L O B A L _ V A R I A B L E _ S I Z E | M E M _ A L L O C _ S I Z E | N U M _ S U B _ G R O U P S | O N _ D E V I C E _ ( ? : E V E N T S | Q U E U E S ) | P A R A M E T E R _ S I Z E | P I P E _ A R G S | R E A D _ I M A G E _ A R G S | R E A D _ W R I T E _ I M A G E _ A R G S | S A M P L E R S | W O R K _ G R O U P _ S I Z E | W O R K _ I T E M _ D I M E N S I O N S | W O R K _ I T E M _ S I Z E S | W R I T E _ I M A G E _ A R G S ) | M E M _ B A S E _ A D D R _ A L I G N | M I N _ D A T A _ T Y P E _ A L I G N _ S I Z E | N A M E | N A T I V E _ V E C T O R _ W I D T H _ ( ? : C H A R | D O U B L E | F L O A T | H A L F | I N T | L O N G | S H O R T ) | N O T _ ( ? : A V A I L A B L E | F O U N D ) | O P E N C L _ C _ V E R S I O N | P A R E N T _ D E V I C E | P A R T I T I O N _ ( ? : A F F I N I T Y _ D O M A I N | B Y _ A F F I N I T Y _ D O M A I N | B Y _ C O U N T S | B Y _ C O U N T S _ L I S T _ E N D | E Q U A L L Y | F A I L E D | M A X _ S U B _ D E V I C E S | P R O P E R T I E S | T Y P E ) | P I P E _ M A X _ ( ? : A C T I V E _ R E S E R V A T I O N S | P A C K E T _ S I Z E ) | P L A T F O R M | P R E F E R R E D _ ( ? : G L O B A L _ A T O M I C _ A L I G N M E N T | I N T E R O P _ U S E R _ S Y N C | L O C A L _ A T O M I C _ A L I G N M E N T | P L A T F O R M _ A T O M I C _ A L I G N M E N T | V E C T O R _ W I D T H _ ( ? : C H A R | D O U B L E | F L O A T | H A L F | I N T | L O N G | S H O R T ) ) | P R I N T F _ B U F F E R _ S I Z E | P R O F I L E | P R O F I L I N G _ T I M E R _ R E S O L U T I O N | Q U E U E _ ( ? : O N _ ( ? : D E V I C E _ ( ? : M A X _ S I Z E | P R E F E R R E D _ S I Z E | P R O P E R T I E S ) | H O S T _ P R O P E R T I E S ) | P R O P E R T I E S ) | R E F E R E N C E _ C O U N T | S I N G L E _ F P _ C O N F I G | S U B _ G R O U P _ I N D E P E N D E N T _ F O R W A R D _ P R O G R E S S | S V M _ ( ? : A T O M I C S | C A P A B I L I T I E S | C O A R S E _ G R A I N _ B U F F E R | F I N E _ G R A I N _ B U F F E R | F I N E _ G R A I N _ S Y S T E M ) | T Y P E ( ? : _ A C C E L E R A T O R | _ A L L | _ C P U | _ C U S T O M | _ D E F A U L T | _ G P U ) ? | V E N D O R ( ? : _ I D ) ? | V E R S I O N ) | D R I V E R _ V E R S I O N | E V E N T _ ( ? : C O M M A N D _ ( ? : E X E C U T I O N _ S T A T U S | Q U E U E | T Y P E ) | C O N T E X T | R E F E R E N C E _ C O U N T ) | E X E C _ ( ? : K E R N E L | N A T I V E _ K E R N E L | S T A T U S _ E R R O R _ F O R _ E V E N T S _ I N _ W A I T _ L I S T ) | F I L T E R _ ( ? : L I N E A R | N E A R E S T ) | F L O A T | F P _ ( ? : C O R R E C T L Y _ R O U N D E D _ D I V I D E _ S Q R T | D E N O R M | F M A | I N F _ N A N | R O U N D _ T O _ I N F | R O U N D _ T O _ N E A R E S T | R O U N D _ T O _ Z E R O | S O F T _ F L O A T ) | G L O B A L | H A L F _ F L O A T | I M A G E _ ( ? : A R R A Y _ S I Z E | B U F F E R | D E P T H | E L E M E N T _ S I Z E | F O R M A T | F O R M A T _ M I S M A T C H | F O R M A T _ N O T _ S U P P O R T E D | H E I G H T | N U M _ M I P _ L E V E L S | N U M _ S A M P L E S | R O W _ P I T C H | S L I C E _ P I T C H | W I D T H ) | I N T E N S I T Y | I N V A L I D _ ( ? : A R G _ I N D E X | A R G _ S I Z E | A R G _ V A L U E | B I N A R Y | B U F F E R _ S I Z E | B U I L D _ O P T I O N S | C O M M A N D _ Q U E U E | C O M P I L E R _ O P T I O N S | C O N T E X T | D E V I C E | D E V I C E _ P A R T I T I O N _ C O U N T | D E V I C E _ Q U E U E | D E V I C E _ T Y P E | E V E N T | E V E N T _ W A I T _ L I S T | G L O B A L _ O F F S E T | G L O B A L _ W O R K _ S I Z E | G L _ O B J E C T | H O S T _ P T R | I M A G E _ D E S C R I P T O R | I M A G E _ F O R M A T _ D E S C R I P T O R | I M A G E _ S I Z E | K E R N E L | K E R N E L _ A R G S | K E R N E L _ D E F I N I T I O N | K E R N E L _ N A M E | L I N K E R _ O P T I O N S | M E M _ O B J E C T | M I P _ L E V E L | O P E R A T I O N | P I P E _ S I Z E | P L A T F O R M | P R O G R A M | P R O G R A M _ E X E C U T A B L E | P R O P E R T Y | Q U E U E _ P R O P E R T I E S | S A M P L E R | V A L U E | W O R K _ D I M E N S I O N | W O R K _ G R O U P _ S I Z E | W O R K _ I T E M _ S I Z E ) | K E R N E L _ ( ? : A R G _ ( ? : A C C E S S _ ( ? : N O N E | Q U A L I F I E R | R E A D _ O N L Y | R E A D _ W R I T E | W R I T E _ O N L Y ) | A D D R E S S _ ( ? : C O N S T A N T | G L O B A L | L O C A L | P R I V A T E | Q U A L I F I E R ) | I N F O _ N O T _ A V A I L A B L E | N A M E | T Y P E _ ( ? : C O N S T | N A M E | N O N E | P I P E | Q U A L I F I E R | R E S T R I C T | V O L A T I L E ) ) | A T T R I B U T E S | C O M P I L E _ N U M _ S U B _ G R O U P S | C O M P I L E _ W O R K _ G R O U P _ S I Z E | C O N T E X T | E X E C _ I N F O _ S V M _ F I N E _ G R A I N _ S Y S T E M | E X E C _ I N F O _ S V M _ P T R S | F U N C T I O N _ N A M E | G L O B A L _ W O R K _ S I Z E | L O C A L _ M E M _ S I Z E | L O C A L _ S I Z E _ F O R _ S U B _ G R O U P _ C O U N T | M A X _ N U M _ S U B _ G R O U P S | M A X _ S U B _ G R O U P _ S I Z E _ F O R _ N D R A N G E | N U M _ A R G S | P R E F E R R E D _ W O R K _ G R O U P _ S I Z E _ M U L T I P L E | P R I V A T E _ M E M _ S I Z E | P R O G R A M | R E F E R E N C E _ C O U N T | S U B _ G R O U P _ C O U N T _ F O R _ N D R A N G E | W O R K _ G R O U P _ S I Z E ) | L I N K E R _ N O T _ A V A I L A B L E | L I N K _ P R O G R A M _ F A I L U R E | L O C A L | L U M I N A N C E | M A P _ ( ? : F A I L U R E | R E A D | W R I T E | W R I T E _ I N V A L I D A
alias : 'constant'
} ,
// Extracted from cl.h (2.0) and http://streamcomputing.eu/downloads/?opencl_host.lang (opencl-host)
'function-opencl-host' : {
pattern : /\bcl(?:BuildProgram|CloneKernel|CompileProgram|Create(?:Buffer|CommandQueue(?:WithProperties)?|Context|ContextFromType|Image|Image2D|Image3D|Kernel|KernelsInProgram|Pipe|ProgramWith(?:Binary|BuiltInKernels|IL|Source)|Sampler|SamplerWithProperties|SubBuffer|SubDevices|UserEvent)|Enqueue(?:(?:Barrier|Marker)(?:WithWaitList)?|Copy(?:Buffer(?:Rect|ToImage)?|Image(?:ToBuffer)?)|(?:Fill|Map)(?:Buffer|Image)|MigrateMemObjects|NDRangeKernel|NativeKernel|(?:Read|Write)(?:Buffer(?:Rect)?|Image)|SVM(?:Free|Map|MemFill|Memcpy|MigrateMem|Unmap)|Task|UnmapMemObject|WaitForEvents)|Finish|Flush|Get(?:CommandQueueInfo|ContextInfo|Device(?:AndHostTimer|IDs|Info)|Event(?:Profiling)?Info|ExtensionFunctionAddress(?:ForPlatform)?|HostTimer|ImageInfo|Kernel(?:ArgInfo|Info|SubGroupInfo|WorkGroupInfo)|MemObjectInfo|PipeInfo|Platform(?:IDs|Info)|Program(?:Build)?Info|SamplerInfo|SupportedImageFormats)|LinkProgram|(?:Release|Retain)(?:CommandQueue|Context|Device|Event|Kernel|MemObject|Program|Sampler)|SVM(?:Alloc|Free)|Set(?:CommandQueueProperty|DefaultDeviceCommandQueue|EventCallback|Kernel|Kernel(?:Arg(?:SVMPointer)?|ExecInfo)|MemObjectDestructorCallback|UserEventStatus)|Unload(?:Platform)?Compiler|WaitForEvents)\b/ ,
alias : 'function'
}
} ;
/* OpenCL host API */
Prism . languages . insertBefore ( 'c' , 'keyword' , attributes ) ;
// C++ includes everything from the OpenCL C host API plus the classes defined in cl2.h
if ( Prism . languages . cpp ) {
// Extracted from doxygen class list http://github.khronos.org/OpenCL-CLHPP/annotated.html
attributes [ 'type-opencl-host-cpp' ] = {
pattern : /\b(?:Buffer|BufferGL|BufferRenderGL|CommandQueue|Context|Device|DeviceCommandQueue|EnqueueArgs|Event|Image|Image1D|Image1DArray|Image1DBuffer|Image2D|Image2DArray|Image2DGL|Image3D|Image3DGL|ImageFormat|ImageGL|Kernel|KernelFunctor|LocalSpaceArg|Memory|NDRange|Pipe|Platform|Program|SVMAllocator|SVMTraitAtomic|SVMTraitCoarse|SVMTraitFine|SVMTraitReadOnly|SVMTraitReadWrite|SVMTraitWriteOnly|Sampler|UserEvent)\b/ ,
alias : 'keyword'
} ;
Prism . languages . insertBefore ( 'cpp' , 'keyword' , attributes ) ;
}
} ( Prism ) ) ;