Skip to content

Latest commit

 

History

History
120 lines (96 loc) · 4.46 KB

TASKS.md

File metadata and controls

120 lines (96 loc) · 4.46 KB

Offline Kernel Compilation

This extension provides predefined set of VS Code tasks for kernel compilation using ioc32/ioc64 or openclc (on macOS).

Content

Run Predefined Task

  1. Press Terminal > Run Task... (fig. 1)

  2. Press Run Task... and select one of the predefined opencl tasks for file kernel.cl. The set of tasks (fig. 2) is generated for each kernel file that was found in the current workspace.

fig 1 fig 2
Figure 1. Terminal menu. Figure 2. Predefined Tasks for openclc compiler.

Configure Default Build Task

Press Terminal > Configure Default Build Task.... Select one of the predefined opencl tasks. File tasks.json will be created (or extended) with configuration of the selected task. Press Ctrl+Shift+B to call it with the shortcut.

It is possible to override selected task definition. It is important to change the field type of the task from opencl to shell, otherwise the task will be ignored.

An example of configurable task for an openclc offline compiler:

tasks.json
{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell", // replace `opencl` with `shell`
            "label": "opencl: custom build [kernel] {gpu_64}",
            "command": "/System/Library/Frameworks/OpenCL.framework/Libraries/openclc",
            "args": [
                "-emit-llvm",
                "-c",
                "-arch",
                "gpu_64",
                "kernel.cl",
                "-o kernel.gpu_64.bc"
            ],
            "problemMatcher": [
                "$opencl.common",
                "$opencl.openclc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

Customize Build Task

Press Terminal > Configure Tasks.... Select one of the predefined opencl tasks. File tasks.json will be created (or extended) with configuration of the selected task.

It is important to change the field type of a task from opencl to shell, otherwise the task will be ignored. Fields command and args may be overridden for using another compiler. Field label is a displayed task name. problemMatcher should be overridden to match a compiler's errors and warnings so messages could be displayed in Problems view.

An example of modified tasks.json configuration file for using AMD Mali as OpenCL offline compiler:

tasks.json
{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "label": "opencl: malisc compile",
            "command": "malisc",
            "args": [
                "--name kernelName",
                "kernel.cl"
            ],
            "problemMatcher": [
                {
                    "owner": "opencl",
                    "fileLocation": ["relative", "${workspaceFolder}"],
                    "pattern": {
                        "regexp": "^(ERROR|WARNING): <(.*)>:(\\d+):(\\d+): (error|warning): (.*)$",
                        "file": 2,
                        "line": 3,
                        "column": 4,
                        "severity": 1,
                        "message": 6
                    }
                }
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

This code will execute malisc --name kernelName kernel.cl on Ctrl+Shift+B press. Field problemMatcher is also customized to parse error/warning messages generated by malisc e.g.:

ERROR: <source>:56:25: error: used type 'float' where floating point type is not allowed
                        float cN = eval_func ? exponential(abs(deltaN), thresh)
                                   ~~~~~~~~~ ^

Customized tasks can also be bound to a custom shortcuts (See Binding keyboard shortcuts to tasks).