Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>PyCUDA highlighterNew to Visual Studio Code? Get it now.
PyCUDA highlighter

PyCUDA highlighter

huangyuyao

|
4,502 installs
| (0) | Free
This extension highlights embedded cuda sources in python script.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

PyCUDA highlighter for VSCode

Highlight CUDA Docstring

Use //cuda and //!cuda to specify a docstring as embedded cuda, then the highlight will work. For example:

import pycuda.driver as drv
import pycuda.tools
import pycuda.autoinit
import numpy
import numpy.linalg as la
from pycuda.compiler import SourceModule

mod = SourceModule("""
//cuda
__global__ void multiply_them(float *dest, float *a, float *b)
{
  const int i = threadIdx.x;
  dest[i] = a[i] * b[i];
}
//!cuda
""")

multiply_them = mod.get_function("multiply_them")

a = numpy.random.randn(400).astype(numpy.float32)
b = numpy.random.randn(400).astype(numpy.float32)

dest = numpy.zeros_like(a)
multiply_them(
        drv.Out(dest), drv.In(a), drv.In(b),
        block=(400,1,1))

print(dest-a*b)
Highlight CUDA Docstring

Customize text color

The text color can be customized by adding following configs to the user settings.json file (or default is the docstring color of python).

    "editor.tokenColorCustomizations": {
      "textMateRules": [
          {
              "scope": "meta.embedded.block.cuda-cpp",
              "settings": {
                  "foreground": "#080644"
              }
          }
      ]
    },

Author

Copyright (c) 2022, Yuyao Huang (huangyuyao at outlook dot com), currently a PhD candidate in Tongji University, Shanghai.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft