mirror of
https://github.com/vosen/ZLUDA.git
synced 2025-04-28 13:37:57 +03:00
Add OGL interop to cuda proc macros
This commit is contained in:
parent
6f76c8b34c
commit
07aa1103aa
6 changed files with 5894 additions and 5750 deletions
|
@ -1 +1 @@
|
|||
bindgen /usr/local/cuda/include/cuda.h -o src/cuda.rs --with-derive-eq --whitelist-function="^cu.*" --whitelist-var="^CU.*" --size_t-is-usize --default-enum-style=newtype --no-layout-tests --no-doc-comments --no-derive-debug --new-type-alias "^CUdevice_v\d+$|^CUdeviceptr_v\d+$" --must-use-type "cudaError_enum" -- -D__CUDA_API_VERSION_INTERNAL
|
||||
bindgen build/wrapper.h -o src/cuda.rs --no-partialeq "CUDA_HOST_NODE_PARAMS_st" --with-derive-eq --whitelist-function="^cu.*" --whitelist-var="^CU.*" --size_t-is-usize --default-enum-style=newtype --no-layout-tests --no-doc-comments --no-derive-debug --new-type-alias "^CUdevice_v\d+$|^CUdeviceptr_v\d+$" --must-use-type "cudaError_enum" -- -I/usr/local/cuda/include
|
3
cuda_base/build/wrapper.h
Normal file
3
cuda_base/build/wrapper.h
Normal file
|
@ -0,0 +1,3 @@
|
|||
#define __CUDA_API_VERSION_INTERNAL
|
||||
#include <cuda.h>
|
||||
#include <cudaGL.h>
|
|
@ -32,6 +32,10 @@ pub const CU_TRSF_NORMALIZED_COORDINATES: u32 = 2;
|
|||
pub const CU_TRSF_SRGB: u32 = 16;
|
||||
pub const CU_TRSF_DISABLE_TRILINEAR_OPTIMIZATION: u32 = 32;
|
||||
pub const CU_PARAM_TR_DEFAULT: i32 = -1;
|
||||
pub const CURRENT_IMPORT_REDIRECTION_VERSION: u32 = 1;
|
||||
pub const CURVECAPS: u32 = 28;
|
||||
pub const CURSOR_SHOWING: u32 = 1;
|
||||
pub const CUR_BLOB_VERSION: u32 = 2;
|
||||
pub type cuuint32_t = u32;
|
||||
pub type cuuint64_t = u64;
|
||||
#[repr(transparent)]
|
||||
|
@ -5703,3 +5707,130 @@ extern "C" {
|
|||
flags: ::std::os::raw::c_uint,
|
||||
) -> CUresult;
|
||||
}
|
||||
pub type GLenum = ::std::os::raw::c_uint;
|
||||
pub type GLuint = ::std::os::raw::c_uint;
|
||||
pub type HGPUNV = *mut ::std::os::raw::c_void;
|
||||
extern "C" {
|
||||
pub fn cuGraphicsGLRegisterBuffer(
|
||||
pCudaResource: *mut CUgraphicsResource,
|
||||
buffer: GLuint,
|
||||
Flags: ::std::os::raw::c_uint,
|
||||
) -> CUresult;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn cuGraphicsGLRegisterImage(
|
||||
pCudaResource: *mut CUgraphicsResource,
|
||||
image: GLuint,
|
||||
target: GLenum,
|
||||
Flags: ::std::os::raw::c_uint,
|
||||
) -> CUresult;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn cuWGLGetDevice(pDevice: *mut CUdevice, hGpu: HGPUNV) -> CUresult;
|
||||
}
|
||||
impl CUGLDeviceList_enum {
|
||||
pub const CU_GL_DEVICE_LIST_ALL: CUGLDeviceList_enum = CUGLDeviceList_enum(1);
|
||||
}
|
||||
impl CUGLDeviceList_enum {
|
||||
pub const CU_GL_DEVICE_LIST_CURRENT_FRAME: CUGLDeviceList_enum = CUGLDeviceList_enum(2);
|
||||
}
|
||||
impl CUGLDeviceList_enum {
|
||||
pub const CU_GL_DEVICE_LIST_NEXT_FRAME: CUGLDeviceList_enum = CUGLDeviceList_enum(3);
|
||||
}
|
||||
#[repr(transparent)]
|
||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
||||
pub struct CUGLDeviceList_enum(pub ::std::os::raw::c_uint);
|
||||
pub use self::CUGLDeviceList_enum as CUGLDeviceList;
|
||||
extern "C" {
|
||||
pub fn cuGLGetDevices_v2(
|
||||
pCudaDeviceCount: *mut ::std::os::raw::c_uint,
|
||||
pCudaDevices: *mut CUdevice,
|
||||
cudaDeviceCount: ::std::os::raw::c_uint,
|
||||
deviceList: CUGLDeviceList,
|
||||
) -> CUresult;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn cuGLCtxCreate_v2(
|
||||
pCtx: *mut CUcontext,
|
||||
Flags: ::std::os::raw::c_uint,
|
||||
device: CUdevice,
|
||||
) -> CUresult;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn cuGLInit() -> CUresult;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn cuGLRegisterBufferObject(buffer: GLuint) -> CUresult;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn cuGLMapBufferObject_v2_ptds(
|
||||
dptr: *mut CUdeviceptr,
|
||||
size: *mut usize,
|
||||
buffer: GLuint,
|
||||
) -> CUresult;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn cuGLUnmapBufferObject(buffer: GLuint) -> CUresult;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn cuGLUnregisterBufferObject(buffer: GLuint) -> CUresult;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn cuGLSetBufferObjectMapFlags(buffer: GLuint, Flags: ::std::os::raw::c_uint) -> CUresult;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn cuGLMapBufferObjectAsync_v2_ptsz(
|
||||
dptr: *mut CUdeviceptr,
|
||||
size: *mut usize,
|
||||
buffer: GLuint,
|
||||
hStream: CUstream,
|
||||
) -> CUresult;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn cuGLUnmapBufferObjectAsync(buffer: GLuint, hStream: CUstream) -> CUresult;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn cuGLGetDevices(
|
||||
pCudaDeviceCount: *mut ::std::os::raw::c_uint,
|
||||
pCudaDevices: *mut CUdevice,
|
||||
cudaDeviceCount: ::std::os::raw::c_uint,
|
||||
deviceList: CUGLDeviceList,
|
||||
) -> CUresult;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn cuGLMapBufferObject_v2(
|
||||
dptr: *mut CUdeviceptr,
|
||||
size: *mut usize,
|
||||
buffer: GLuint,
|
||||
) -> CUresult;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn cuGLMapBufferObjectAsync_v2(
|
||||
dptr: *mut CUdeviceptr,
|
||||
size: *mut usize,
|
||||
buffer: GLuint,
|
||||
hStream: CUstream,
|
||||
) -> CUresult;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn cuGLCtxCreate(
|
||||
pCtx: *mut CUcontext,
|
||||
Flags: ::std::os::raw::c_uint,
|
||||
device: CUdevice,
|
||||
) -> CUresult;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn cuGLMapBufferObject(
|
||||
dptr: *mut CUdeviceptr_v1,
|
||||
size: *mut ::std::os::raw::c_uint,
|
||||
buffer: GLuint,
|
||||
) -> CUresult;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn cuGLMapBufferObjectAsync(
|
||||
dptr: *mut CUdeviceptr_v1,
|
||||
size: *mut ::std::os::raw::c_uint,
|
||||
buffer: GLuint,
|
||||
hStream: CUstream,
|
||||
) -> CUresult;
|
||||
}
|
||||
|
|
|
@ -204,7 +204,11 @@ fn prepend_cuda_path_to_path(base_path: &Path, path: Path) -> Path {
|
|||
}
|
||||
if path.segments.len() == 1 {
|
||||
let ident = path.segments[0].ident.to_string();
|
||||
if ident.starts_with("CU") || ident.starts_with("cu") {
|
||||
if ident.starts_with("CU")
|
||||
|| ident.starts_with("cu")
|
||||
|| ident.starts_with("GL")
|
||||
|| ident == "HGPUNV"
|
||||
{
|
||||
let mut base_path = base_path.clone();
|
||||
base_path.segments.extend(path.segments);
|
||||
return base_path;
|
||||
|
@ -243,7 +247,7 @@ impl Parse for FnDeclInput {
|
|||
// This trait accepts following parameters:
|
||||
// * `type_path`: path to the module with type definitions (in the module tree)
|
||||
// * `trait_`: name of the trait to be derived
|
||||
// * `ignore_structs`: bracketed list of types to ignore
|
||||
// * `ignore_types`: bracketed list of types to ignore
|
||||
// * `ignore_fns`: bracketed list of fns to ignore
|
||||
#[proc_macro]
|
||||
pub fn cuda_derive_display_trait(tokens: TokenStream) -> TokenStream {
|
||||
|
@ -331,7 +335,7 @@ fn cuda_derive_display_trait_for_item(
|
|||
}
|
||||
Item::Struct(item_struct) => {
|
||||
let item_struct_name = item_struct.ident.to_string();
|
||||
if state.ignore_structs.contains(&item_struct.ident) {
|
||||
if state.ignore_types.contains(&item_struct.ident) {
|
||||
return None;
|
||||
}
|
||||
if item_struct_name.ends_with("_enum") {
|
||||
|
@ -384,7 +388,11 @@ fn cuda_derive_display_trait_for_item(
|
|||
})
|
||||
}
|
||||
}
|
||||
Item::Type(item_type) => match *(item_type.ty) {
|
||||
Item::Type(item_type) => {
|
||||
if state.ignore_types.contains(&item_type.ident) {
|
||||
return None;
|
||||
};
|
||||
match *(item_type.ty) {
|
||||
Type::Ptr(_) => {
|
||||
let type_ = item_type.ident;
|
||||
Some(quote! {
|
||||
|
@ -420,7 +428,8 @@ fn cuda_derive_display_trait_for_item(
|
|||
None
|
||||
}
|
||||
_ => unreachable!(),
|
||||
},
|
||||
}
|
||||
}
|
||||
Item::Union(_) => None,
|
||||
Item::Use(_) => None,
|
||||
_ => unreachable!(),
|
||||
|
@ -430,7 +439,7 @@ fn cuda_derive_display_trait_for_item(
|
|||
struct DeriveDisplayState {
|
||||
type_path: Path,
|
||||
trait_: Path,
|
||||
ignore_structs: FxHashSet<Ident>,
|
||||
ignore_types: FxHashSet<Ident>,
|
||||
ignore_fns: FxHashSet<Ident>,
|
||||
enums: FxHashMap<Ident, Vec<Ident>>,
|
||||
}
|
||||
|
@ -440,7 +449,7 @@ impl DeriveDisplayState {
|
|||
DeriveDisplayState {
|
||||
type_path: input.type_path,
|
||||
trait_: input.trait_,
|
||||
ignore_structs: input.ignore_structs.into_iter().collect(),
|
||||
ignore_types: input.ignore_types.into_iter().collect(),
|
||||
ignore_fns: input.ignore_fns.into_iter().collect(),
|
||||
enums: Default::default(),
|
||||
}
|
||||
|
@ -461,7 +470,7 @@ impl DeriveDisplayState {
|
|||
struct DeriveDisplayInput {
|
||||
type_path: Path,
|
||||
trait_: Path,
|
||||
ignore_structs: Punctuated<Ident, Token![,]>,
|
||||
ignore_types: Punctuated<Ident, Token![,]>,
|
||||
ignore_fns: Punctuated<Ident, Token![,]>,
|
||||
}
|
||||
|
||||
|
@ -471,9 +480,9 @@ impl Parse for DeriveDisplayInput {
|
|||
input.parse::<Token![,]>()?;
|
||||
let trait_ = input.parse::<Path>()?;
|
||||
input.parse::<Token![,]>()?;
|
||||
let ignore_structs_buffer;
|
||||
bracketed!(ignore_structs_buffer in input);
|
||||
let ignore_structs = ignore_structs_buffer.parse_terminated(Ident::parse)?;
|
||||
let ignore_types_buffer;
|
||||
bracketed!(ignore_types_buffer in input);
|
||||
let ignore_types = ignore_types_buffer.parse_terminated(Ident::parse)?;
|
||||
input.parse::<Token![,]>()?;
|
||||
let ignore_fns_buffer;
|
||||
bracketed!(ignore_fns_buffer in input);
|
||||
|
@ -481,7 +490,7 @@ impl Parse for DeriveDisplayInput {
|
|||
Ok(Self {
|
||||
type_path,
|
||||
trait_,
|
||||
ignore_structs,
|
||||
ignore_types,
|
||||
ignore_fns,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
grep -E '^cu.*' log.txt | sed 's/(.*//g' | sort | uniq > uniq_host.txt
|
||||
grep -E '^cu.*' log.txt | sed 's/([^)]*)//g' | sort | uniq > uniq_host.txt
|
||||
cat *.log | grep "^Unrecognized s" | grep -Eo '`([^`]*)`' | sed -E 's/^`((@\w+ )?[^[:space:]]*).*`/\1/' | sort | uniq > uniq_statements.txt
|
||||
cat *.log | grep "^Unrecognized d" | grep -Eo '`([^`]*)`' | sed -E 's/^`([^`]*)`/\1/' | sort | uniq > uniq_directives.txt
|
|
@ -737,7 +737,8 @@ cuda_derive_display_trait!(
|
|||
CUexecAffinityParam_st,
|
||||
CUstreamBatchMemOpParams_union_CUstreamMemOpWaitValueParams_st,
|
||||
CUstreamBatchMemOpParams_union_CUstreamMemOpWriteValueParams_st,
|
||||
CUuuid_st
|
||||
CUuuid_st,
|
||||
HGPUNV
|
||||
],
|
||||
[
|
||||
cuCtxCreate_v3,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue