Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions backends/cuda/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,15 @@ CLEANFILES = \
$(BTX_CUDA_GENERATED) &: $(top_srcdir)/xprof/btx_interval_model.yaml btx_cudamatching_model.yaml btx_cuda_model.yaml
$(METABABEL) -u btx_cuda_model.yaml -d $(top_srcdir)/xprof/btx_interval_model.yaml -t FILTER -o btx_filter_cuda -p cudainterval -c interval --matching $(srcdir)/btx_cudamatching_model.yaml -i cuda.h.include

$(MODIFIED_CUDA_HDR) &: $(CUDA_HDR) $(srcdir)/headers.patch
$(MODIFIED_CUDA_HDR) &: $(CUDA_HDR)
$(RM) -r modified_include/
cp -r $(srcdir)/include/ modified_include/
chmod -R u+w modified_include/
cat $(srcdir)/headers.patch | patch -i - -d modified_include/ -s -p1

clean-local:
$(RM) -r modified_include

EXTRA_DIST += $(srcdir)/include headers.patch
EXTRA_DIST += $(srcdir)/include

CUDA_EXTRACT_H = $(srcdir)/extract/cuda_api.h $(srcdir)/extract/cudart_api.h
EXTRA_DIST += $(CUDA_EXTRACT_H)
Expand Down
7 changes: 7 additions & 0 deletions backends/cuda/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# CUDA Backend

## VDPAU Stub

The CUDA SDK includes interop headers (`cudaVDPAU.h`, `cuda_vdpau_interop.h`) that reference VDPAU types (`VdpDevice`, `VdpGetProcAddress`, etc.) from `<vdpau/vdpau.h>`. This system header is not always available.

A stub is provided in `include/vdpau/vdpau.h` that defines the necessary VDPAU types so that the CUDA tracer can compiled.
9 changes: 1 addition & 8 deletions backends/cuda/extract/cuda_api.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
#define __CUDA_API_VERSION_INTERNAL = 1
#define THAPI_NO_INCLUDE

#include <stdint.h>

#include <cuda.h>

typedef int32_t VdpStatus;
typedef uint32_t VdpFuncId;
typedef uint32_t VdpDevice;
typedef VdpStatus
VdpGetProcAddress(VdpDevice device, VdpFuncId function_id, void **function_pointer);
typedef uint32_t VdpVideoSurface;
typedef uint32_t VdpOutputSurface;
#include <vdpau/vdpau.h>

#include <cudaVDPAU.h>

Expand Down
9 changes: 0 additions & 9 deletions backends/cuda/extract/cudart_api.h
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
#define __CUDA_API_VERSION_INTERNAL = 1
#define THAPI_NO_INCLUDE

#include <stdint.h>

#include <cuda_runtime_api.h>

#include <__cudart.h>

typedef int32_t VdpStatus;
typedef uint32_t VdpFuncId;
typedef uint32_t VdpDevice;
typedef VdpStatus
VdpGetProcAddress(VdpDevice device, VdpFuncId function_id, void **function_pointer);
typedef uint32_t VdpVideoSurface;
typedef uint32_t VdpOutputSurface;

#include <cuda_vdpau_interop.h>

#include <cuda_profiler_api.h>
1 change: 0 additions & 1 deletion backends/cuda/gen_cuda_exports_extract.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

puts <<~EOF
#define __CUDA_API_VERSION_INTERNAL=1
#define THAPI_NO_INCLUDE
#include <cuda.h>
EOF

Expand Down
109 changes: 0 additions & 109 deletions backends/cuda/headers.patch

This file was deleted.

15 changes: 15 additions & 0 deletions backends/cuda/include/vdpau/vdpau.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* Stub for VDPAU types used by CUDA interop headers. */
#ifndef THAPI_VDPAU_STUB_H
#define THAPI_VDPAU_STUB_H

#include <stdint.h>

typedef int32_t VdpStatus;
typedef uint32_t VdpFuncId;
typedef uint32_t VdpDevice;
typedef VdpStatus VdpGetProcAddress(VdpDevice device, VdpFuncId function_id,
void **function_pointer);
typedef uint32_t VdpVideoSurface;
typedef uint32_t VdpOutputSurface;

#endif
31 changes: 22 additions & 9 deletions utils/gen_library_base.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
require_relative 'yaml_ast'

def has_typedef?(name)
$all_types.any? { |t| t.type.respond_to?(:name) && t.type.name == name }
end

def to_ffi_name(name, default = true)
case name
when nil
Expand Down Expand Up @@ -337,18 +341,27 @@ module Composite
def to_ffi
unamed_count = 0
members.map do |m|
mt = if m.type.is_a?(Array)
mt = case m.type
when Array
m.type.to_ffi
elsif m.type.is_a?(Pointer)
when Pointer
':pointer'
elsif m.type.name
to_ffi_name(m.type.name)
elsif m.type.is_a?(Struct)
"(Class::new(#{FFI_STRUCT}) { layout #{gen_layout(m.type.to_ffi)} }.by_value)"
elsif m.type.is_a?(Union)
"(Class::new(#{FFI_UNION}) { layout #{gen_layout(m.type.to_ffi)} }.by_value)"
when Struct
if m.type.name && has_typedef?(m.type.name)
to_ffi_name(m.type.name)
else
s = m.type.name ? $all_structs.find { |st| st.name == m.type.name } : m.type
"(Class::new(#{FFI_STRUCT}) { layout #{gen_layout(s.to_ffi)} }.by_value)"
end
when Union
if m.type.name && has_typedef?(m.type.name)
to_ffi_name(m.type.name)
else
u = m.type.name ? $all_unions&.find { |un| un.name == m.type.name } : m.type
"(Class::new(#{FFI_UNION}) { layout #{gen_layout(u.to_ffi)} }.by_value)"
end
else
raise "unknown type: #{m.type}"
m.type.name ? to_ffi_name(m.type.name) : raise("unknown type: #{m.type}")
end
[m.name ? m.name.to_sym.inspect : ":_unamed_#{unamed_count += 1}", mt]
end
Expand Down
Loading