Skip to content

Commit

Permalink
additional ioctls for L4 gpu
Browse files Browse the repository at this point in the history
  • Loading branch information
2022tgoel committed Jan 2, 2025
1 parent 5aa576b commit 1bbd6f3
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions images/benchmarks/ffmpeg/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ RUN set -x \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /media
ADD https://samples.ffmpeg.org/MPEG-4/video.mp4 video.mp4
ADD https://samples.ffmpeg.org/A-codecs/Nelly_Moser/h264_NellyMoser.mp4 encoded.mp4
5 changes: 5 additions & 0 deletions pkg/abi/nvgpu/ctrl.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,11 @@ const (
NV0080_CTRL_CMD_BSP_GET_CAPS_V2 = 0x801c02
)

// From src/common/sdk/nvidia/inc/ctrl/ctrl0080/ctrl0080nvjpg.h
const (
NV0080_CTRL_CMD_NVJPG_GET_CAPS_V2 = 0x801f02
)

// From src/common/sdk/nvidia/inc/ctrl/ctrl00f8.h:
const (
NV00F8_CTRL_CMD_ATTACH_MEM = 0xf80103
Expand Down
13 changes: 13 additions & 0 deletions pkg/abi/nvgpu/uvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const (
UVM_MAP_DYNAMIC_PARALLELISM_REGION = 65
UVM_UNMAP_EXTERNAL = 66
UVM_ALLOC_SEMAPHORE_POOL = 68
UVM_PAGEABLE_MEM_ACCESS_ON_GPU = 70
UVM_VALIDATE_VA_RANGE = 72
UVM_CREATE_EXTERNAL_RANGE = 73
UVM_MM_INITIALIZE = 75
Expand Down Expand Up @@ -529,6 +530,18 @@ func (p *UVM_ALLOC_SEMAPHORE_POOL_PARAMS_V550) GetStatus() uint32 {
return p.RMStatus
}

// +marshal
type UVM_PAGEABLE_MEM_ACCESS_ON_GPU_PARAMS struct {
GPUUUID NvUUID
PageableMemAccess uint8
Pad [3]byte
RMStatus uint32
}

func (p *UVM_PAGEABLE_MEM_ACCESS_ON_GPU_PARAMS) GetStatus() uint32 {
return p.RMStatus
}

// +marshal
type UVM_VALIDATE_VA_RANGE_PARAMS struct {
Base uint64
Expand Down
4 changes: 4 additions & 0 deletions pkg/sentry/devices/nvproxy/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ func Init() {
nvgpu.UVM_MAP_DYNAMIC_PARALLELISM_REGION: uvmHandler(uvmIoctlSimple[nvgpu.UVM_MAP_DYNAMIC_PARALLELISM_REGION_PARAMS], compUtil),
nvgpu.UVM_UNMAP_EXTERNAL: uvmHandler(uvmIoctlSimple[nvgpu.UVM_UNMAP_EXTERNAL_PARAMS], compUtil),
nvgpu.UVM_ALLOC_SEMAPHORE_POOL: uvmHandler(uvmIoctlSimple[nvgpu.UVM_ALLOC_SEMAPHORE_POOL_PARAMS], compUtil),
nvgpu.UVM_PAGEABLE_MEM_ACCESS_ON_GPU: uvmHandler(uvmIoctlSimple[nvgpu.UVM_PAGEABLE_MEM_ACCESS_ON_GPU_PARAMS], nvconf.CapVideo),
nvgpu.UVM_VALIDATE_VA_RANGE: uvmHandler(uvmIoctlSimple[nvgpu.UVM_VALIDATE_VA_RANGE_PARAMS], compUtil),
nvgpu.UVM_CREATE_EXTERNAL_RANGE: uvmHandler(uvmIoctlSimple[nvgpu.UVM_CREATE_EXTERNAL_RANGE_PARAMS], compUtil),
nvgpu.UVM_MM_INITIALIZE: uvmHandler(uvmMMInitialize, compUtil),
Expand Down Expand Up @@ -261,6 +262,7 @@ func Init() {
nvgpu.NV0080_CTRL_CMD_GPU_GET_CLASSLIST_V2: ctrlHandler(rmControlSimple, compUtil),
nvgpu.NV0080_CTRL_CMD_HOST_GET_CAPS_V2: ctrlHandler(rmControlSimple, compUtil),
nvgpu.NV0080_CTRL_CMD_BSP_GET_CAPS_V2: ctrlHandler(rmControlSimple, nvconf.CapGraphics|nvconf.CapVideo),
nvgpu.NV0080_CTRL_CMD_NVJPG_GET_CAPS_V2: ctrlHandler(rmControlSimple, nvconf.CapVideo),
nvgpu.NV0080_CTRL_CMD_FIFO_GET_ENGINE_CONTEXT_PROPERTIES: ctrlHandler(rmControlSimple, nvconf.CapGraphics),
nvgpu.NV00F8_CTRL_CMD_ATTACH_MEM: ctrlHandler(rmControlSimple, compUtil),
nvgpu.NV00FD_CTRL_CMD_GET_INFO: ctrlHandler(rmControlSimple, compUtil),
Expand Down Expand Up @@ -483,6 +485,7 @@ func Init() {
nvgpu.UVM_MAP_DYNAMIC_PARALLELISM_REGION: driverStructs(nvgpu.UVM_MAP_DYNAMIC_PARALLELISM_REGION_PARAMS{}),
nvgpu.UVM_UNMAP_EXTERNAL: driverStructs(nvgpu.UVM_UNMAP_EXTERNAL_PARAMS{}),
nvgpu.UVM_ALLOC_SEMAPHORE_POOL: driverStructs(nvgpu.UVM_ALLOC_SEMAPHORE_POOL_PARAMS{}),
nvgpu.UVM_PAGEABLE_MEM_ACCESS_ON_GPU: driverStructs(nvgpu.UVM_PAGEABLE_MEM_ACCESS_ON_GPU_PARAMS{}),
nvgpu.UVM_VALIDATE_VA_RANGE: driverStructs(nvgpu.UVM_VALIDATE_VA_RANGE_PARAMS{}),
nvgpu.UVM_CREATE_EXTERNAL_RANGE: driverStructs(nvgpu.UVM_CREATE_EXTERNAL_RANGE_PARAMS{}),
nvgpu.UVM_MM_INITIALIZE: driverStructs(nvgpu.UVM_MM_INITIALIZE_PARAMS{}),
Expand Down Expand Up @@ -517,6 +520,7 @@ func Init() {
nvgpu.NV0080_CTRL_CMD_GPU_GET_CLASSLIST_V2: simpleDriverStruct("NV0080_CTRL_GPU_GET_CLASSLIST_V2_PARAMS"),
nvgpu.NV0080_CTRL_CMD_HOST_GET_CAPS_V2: simpleDriverStruct("NV0080_CTRL_HOST_GET_CAPS_V2_PARAMS"),
nvgpu.NV0080_CTRL_CMD_BSP_GET_CAPS_V2: simpleDriverStruct("NV0080_CTRL_BSP_GET_CAPS_PARAMS_V2"),
nvgpu.NV0080_CTRL_CMD_NVJPG_GET_CAPS_V2: simpleDriverStruct("NV0080_CTRL_CMD_NVJPG_GET_CAPS_V2_PARAMS"),
nvgpu.NV0080_CTRL_CMD_FIFO_GET_ENGINE_CONTEXT_PROPERTIES: simpleDriverStruct("NV0080_CTRL_FIFO_GET_ENGINE_CONTEXT_PROPERTIES_PARAMS"),
nvgpu.NV00F8_CTRL_CMD_ATTACH_MEM: simpleDriverStruct("NV00F8_CTRL_ATTACH_MEM_PARAMS"),
nvgpu.NV00FD_CTRL_CMD_GET_INFO: simpleDriverStruct("NV00FD_CTRL_GET_INFO_PARAMS"),
Expand Down
2 changes: 1 addition & 1 deletion test/gpu/ffmpeg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestFffmpegDecodeGPU(t *testing.T) {
opts.Image = "benchmarks/ffmpeg"
// h264_cuvid refers to NVDEC. See Section 4.2 in
// https://docs.nvidia.com/video-technologies/video-codec-sdk/pdf/Using_FFmpeg_with_NVIDIA_GPU_Hardware_Acceleration.pdf
cmd := []string{"bash", "-c", "ffmpeg -i video.mp4 -c:v h264_nvenc -preset fast output.mp4 && ffmpeg -y -vsync 0 -c:v h264_cuvid -i output.mp4 video.mp4"}
cmd := strings.Split("ffmpeg -y -vsync 0 -c:v h264_cuvid -i encoded.mp4 output.mp4", " ")
if output, err := container.Run(ctx, opts, cmd...); err != nil {
t.Errorf("failed to run container: %v; output:\n%s", err, output)
}
Expand Down

0 comments on commit 1bbd6f3

Please sign in to comment.