Skip to content

Commit bd8b73f

Browse files
rparolinclaude
andcommitted
cuda.core: update texture examples for OpaqueArray / cuda.core.texture rename
The examples still imported `from cuda.core.textures import (CUDAArray, ...)`, which broke after the namespace/class rename. test_basic_examples runs texture_sample.py as a subprocess (no system requirement gating it), so the dead import failed "Run cuda.core tests" across the GPU matrix. Renamed cuda.core.textures -> cuda.core.texture and CUDAArray -> OpaqueArray in all four texture examples. Verified: texture_sample.py runs to completion on a GPU (texel-center + half-integer samples verified, exit 0). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent f66b043 commit bd8b73f

4 files changed

Lines changed: 22 additions & 22 deletions

File tree

cuda_core/examples/gl_interop_fluid.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
# ################################################################################
66
#
7-
# This example demonstrates cuda.core.CUDAArray, TextureObject, and SurfaceObject
7+
# This example demonstrates cuda.core.OpaqueArray, TextureObject, and SurfaceObject
88
# in combination with GraphicsResource for CUDA/OpenGL interop. It runs a
99
# real-time Stable Fluids (Jos Stam) smoke/ink solver entirely on the GPU:
1010
# velocity, pressure, and dye fields live in ping-ponged CUDA arrays, are read
@@ -107,10 +107,10 @@
107107
ProgramOptions,
108108
launch,
109109
)
110-
from cuda.core.textures import (
110+
from cuda.core.texture import (
111111
AddressMode,
112112
ArrayFormat,
113-
CUDAArray,
113+
OpaqueArray,
114114
FilterMode,
115115
ReadMode,
116116
ResourceDescriptor,
@@ -164,7 +164,7 @@
164164
# ============================= Helper functions =============================
165165
#
166166
# The functions below set up CUDA and OpenGL. If you're here to learn about
167-
# CUDAArray/TextureObject/SurfaceObject, skip ahead to main() -- the interesting
167+
# OpaqueArray/TextureObject/SurfaceObject, skip ahead to main() -- the interesting
168168
# part is there. These helpers exist so that main() reads like a short story
169169
# instead of a wall of boilerplate.
170170
# ============================================================================
@@ -248,7 +248,7 @@ def create_window():
248248
window = pyglet.window.Window(
249249
WIDTH,
250250
HEIGHT,
251-
caption="cuda.core CUDAArray/Texture/Surface - Stable Fluids",
251+
caption="cuda.core OpaqueArray/Texture/Surface - Stable Fluids",
252252
vsync=False,
253253
)
254254
return window, _gl, pyglet
@@ -397,11 +397,11 @@ def draw_fullscreen_quad(gl, shader_prog, vao_id, tex_id):
397397

398398
# ============================ API MAP (cuda.core) ===========================
399399
#
400-
# The three helpers below are where every CUDAArray / ResourceDescriptor /
400+
# The three helpers below are where every OpaqueArray / ResourceDescriptor /
401401
# TextureDescriptor / TextureObject / SurfaceObject knob in this example is set.
402402
# Each visible setting maps to a concrete piece of cuda.core / CUDA behavior:
403403
#
404-
# CUDAArray.from_descriptor(...) -> allocates a CUDA *array* (opaque, tiled
404+
# OpaqueArray.from_descriptor(...) -> allocates a CUDA *array* (opaque, tiled
405405
# layout optimized for 2D texture fetches),
406406
# not linear device memory.
407407
# ArrayFormat.FLOAT32 -> each channel is a 32-bit float texel.
@@ -414,7 +414,7 @@ def draw_fullscreen_quad(gl, shader_prog, vao_id, tex_id):
414414
# is what lets each field be sampled and
415415
# then written back in the ping-pong.
416416
#
417-
# ResourceDescriptor.from_array(arr) -> wraps the CUDAArray as the resource a
417+
# ResourceDescriptor.from_array(arr) -> wraps the OpaqueArray as the resource a
418418
# TextureObject reads from.
419419
# FilterMode.LINEAR -> free HARDWARE bilinear interpolation;
420420
# this is what makes semi-Lagrangian
@@ -438,7 +438,7 @@ def draw_fullscreen_quad(gl, shader_prog, vao_id, tex_id):
438438

439439
def make_velocity_array():
440440
"""Allocate a `float2` velocity CUDA array (channel 0 = vx, channel 1 = vy)."""
441-
return CUDAArray.from_descriptor(
441+
return OpaqueArray.from_descriptor(
442442
shape=(WIDTH, HEIGHT),
443443
format=ArrayFormat.FLOAT32,
444444
num_channels=2,
@@ -448,7 +448,7 @@ def make_velocity_array():
448448

449449
def make_scalar_array():
450450
"""Allocate a single-channel `float` CUDA array (pressure / divergence / dye)."""
451-
return CUDAArray.from_descriptor(
451+
return OpaqueArray.from_descriptor(
452452
shape=(WIDTH, HEIGHT),
453453
format=ArrayFormat.FLOAT32,
454454
num_channels=1,
@@ -464,7 +464,7 @@ def make_color_array():
464464
surface-write machinery as the scalar fields -- only the channel count
465465
(and the surf2Dwrite byte stride, sizeof(float4) = 16) differ.
466466
"""
467-
return CUDAArray.from_descriptor(
467+
return OpaqueArray.from_descriptor(
468468
shape=(WIDTH, HEIGHT),
469469
format=ArrayFormat.FLOAT32,
470470
num_channels=4,
@@ -876,7 +876,7 @@ def on_draw():
876876
if now - fps_time >= 1.0:
877877
fps = frame_count / (now - fps_time)
878878
window.set_caption(
879-
"cuda.core CUDAArray/Texture/Surface - Stable Fluids"
879+
"cuda.core OpaqueArray/Texture/Surface - Stable Fluids"
880880
f" ({WIDTH}x{HEIGHT}, {fps:.0f} FPS,"
881881
f" {PRESSURE_ITERS} pressure iters)"
882882
" | TextureObject[LINEAR|CLAMP|norm|float2]"

cuda_core/examples/gl_interop_fluid_numba_cuda_mlir.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
# =======================================
2222
# cuda.core / CUDA C++ -> numba-cuda (this file)
2323
# -------------------------------------- -----------------------------------
24-
# CUDAArray(num_channels=2) as texture -> cuda.device_array((H, W, 2), f32)
24+
# OpaqueArray(num_channels=2) as texture -> cuda.device_array((H, W, 2), f32)
2525
# tex2D<float2>(tex, u, v) [HW LINEAR] -> sample_vec(arr, px, py) [manual lerp]
2626
# AddressMode.CLAMP -> index clamp inside sample_*()
2727
# surf2Dwrite(v, surf, x*8, y) -> arr[y, x, 0] = v.x; arr[y, x, 1] = v.y

cuda_core/examples/gl_interop_mipmap_lod.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
# | +---- one SurfaceObject per level, used at BUILD time only
4646
# | to let a kernel write pixels into that level.
4747
# |
48-
# +----------- get_level(L) returns a NON-OWNING CUDAArray view of level L;
48+
# +----------- get_level(L) returns a NON-OWNING OpaqueArray view of level L;
4949
# the storage belongs to the parent MipmappedArray.
5050
#
5151
# STARTUP -- one-time mipmap build
@@ -100,7 +100,7 @@
100100
ProgramOptions,
101101
launch,
102102
)
103-
from cuda.core.textures import (
103+
from cuda.core.texture import (
104104
AddressMode,
105105
ArrayFormat,
106106
FilterMode,
@@ -577,7 +577,7 @@ def on_close():
577577
// --------------------------------------------------------------------------
578578
// seed_base: write a procedural high-frequency pattern to level 0.
579579
//
580-
// surf is a SurfaceObject bound to the level-0 CUDAArray (float4 RGBA). The
580+
// surf is a SurfaceObject bound to the level-0 OpaqueArray (float4 RGBA). The
581581
// pattern is a colorful blend of concentric rings, a diagonal grid, and a
582582
// radial sweep, designed to have plenty of fine detail so the difference
583583
// between mip levels is visually obvious.

cuda_core/examples/texture_sample.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
# ################################################################################
66
#
7-
# This example demonstrates building a 2D CUDA CUDAArray, binding it as a
7+
# This example demonstrates building a 2D CUDA OpaqueArray, binding it as a
88
# bindless TextureObject, and sampling it from a kernel with both POINT-exact
99
# and LINEAR-interpolated coordinates.
1010
#
@@ -29,10 +29,10 @@
2929
ProgramOptions,
3030
launch,
3131
)
32-
from cuda.core.textures import (
32+
from cuda.core.texture import (
3333
AddressMode,
3434
ArrayFormat,
35-
CUDAArray,
35+
OpaqueArray,
3636
FilterMode,
3737
ReadMode,
3838
ResourceDescriptor,
@@ -65,12 +65,12 @@ def main():
6565

6666
pinned_mr = LegacyPinnedMemoryResource()
6767
try:
68-
# Allocate a 2D CUDAArray: shape=(W, H), single-channel float32.
69-
# Note: CUDAArray.from_descriptor takes shape=(width, height), so the host
68+
# Allocate a 2D OpaqueArray: shape=(W, H), single-channel float32.
69+
# Note: OpaqueArray.from_descriptor takes shape=(width, height), so the host
7070
# buffer fed into copy_from must be laid out as H rows of W elements
7171
# (row-major), i.e. host_pattern.shape == (H, W).
7272
width, height = 16, 16
73-
with CUDAArray.from_descriptor(
73+
with OpaqueArray.from_descriptor(
7474
shape=(width, height),
7575
format=ArrayFormat.FLOAT32,
7676
num_channels=1,

0 commit comments

Comments
 (0)