pub trait DevicePtr{
Show 66 methods
// Required method
unsafe fn device_ptr(&self) -> cl_device_id;
// Provided methods
fn is_usable(&self) -> bool { ... }
fn usability_check(&self) -> Output<()> { ... }
fn global_mem_cacheline_size(&self) -> Output<u32> { ... }
fn native_vector_width_double(&self) -> Output<u32> { ... }
fn native_vector_width_half(&self) -> Output<u32> { ... }
fn address_bits(&self) -> Output<u32> { ... }
fn max_clock_frequency(&self) -> Output<u32> { ... }
fn max_compute_units(&self) -> Output<u32> { ... }
fn max_constant_args(&self) -> Output<u32> { ... }
fn max_read_image_args(&self) -> Output<u32> { ... }
fn max_samplers(&self) -> Output<u32> { ... }
fn max_work_item_dimensions(&self) -> Output<u32> { ... }
fn max_write_image_args(&self) -> Output<u32> { ... }
fn mem_base_addr_align(&self) -> Output<u32> { ... }
fn min_data_type_align_size(&self) -> Output<u32> { ... }
fn native_vector_width_char(&self) -> Output<u32> { ... }
fn native_vector_width_short(&self) -> Output<u32> { ... }
fn native_vector_width_int(&self) -> Output<u32> { ... }
fn native_vector_width_long(&self) -> Output<u32> { ... }
fn native_vector_width_float(&self) -> Output<u32> { ... }
fn partition_max_sub_devices(&self) -> Output<u32> { ... }
fn preferred_vector_width_char(&self) -> Output<u32> { ... }
fn preferred_vector_width_short(&self) -> Output<u32> { ... }
fn preferred_vector_width_int(&self) -> Output<u32> { ... }
fn preferred_vector_width_long(&self) -> Output<u32> { ... }
fn preferred_vector_width_float(&self) -> Output<u32> { ... }
fn preferred_vector_width_double(&self) -> Output<u32> { ... }
fn preferred_vector_width_half(&self) -> Output<u32> { ... }
fn vendor_id(&self) -> Output<u32> { ... }
fn available(&self) -> Output<bool> { ... }
fn compiler_available(&self) -> Output<bool> { ... }
fn endian_little(&self) -> Output<bool> { ... }
fn error_correction_support(&self) -> Output<bool> { ... }
fn host_unified_memory(&self) -> Output<bool> { ... }
fn image_support(&self) -> Output<bool> { ... }
fn linker_available(&self) -> Output<bool> { ... }
fn preferred_interop_user_sync(&self) -> Output<bool> { ... }
fn name(&self) -> Output<String> { ... }
fn opencl_c_version(&self) -> Output<String> { ... }
fn profile(&self) -> Output<String> { ... }
fn vendor(&self) -> Output<String> { ... }
fn version(&self) -> Output<String> { ... }
fn driver_version(&self) -> Output<String> { ... }
fn global_mem_cache_size(&self) -> Output<u64> { ... }
fn global_mem_size(&self) -> Output<u64> { ... }
fn local_mem_size(&self) -> Output<u64> { ... }
fn max_constant_buffer_size(&self) -> Output<u64> { ... }
fn max_mem_alloc_size(&self) -> Output<u64> { ... }
fn image2d_max_width(&self) -> Output<usize> { ... }
fn image2d_max_height(&self) -> Output<usize> { ... }
fn image3d_max_width(&self) -> Output<usize> { ... }
fn image3d_max_height(&self) -> Output<usize> { ... }
fn image3d_max_depth(&self) -> Output<usize> { ... }
fn image_max_buffer_size(&self) -> Output<usize> { ... }
fn image_max_array_size(&self) -> Output<usize> { ... }
fn max_parameter_size(&self) -> Output<usize> { ... }
fn max_work_group_size(&self) -> Output<usize> { ... }
fn printf_buffer_size(&self) -> Output<usize> { ... }
fn profiling_timer_resolution(&self) -> Output<usize> { ... }
fn max_work_item_sizes(&self) -> Output<Vec<usize>> { ... }
fn local_mem_type(&self) -> Output<DeviceLocalMemType> { ... }
fn execution_capabilities(&self) -> Output<DeviceExecCapabilities> { ... }
fn global_mem_cache_type(&self) -> Output<DeviceMemCacheType> { ... }
fn partition_affinity_domain(&self) -> Output<DeviceAffinityDomain> { ... }
fn device_type(&self) -> Output<DeviceType> { ... }
}Required Methods§
unsafe fn device_ptr(&self) -> cl_device_id
Provided Methods§
fn is_usable(&self) -> bool
fn usability_check(&self) -> Output<()>
fn global_mem_cacheline_size(&self) -> Output<u32>
fn native_vector_width_double(&self) -> Output<u32>
fn native_vector_width_half(&self) -> Output<u32>
fn address_bits(&self) -> Output<u32>
fn max_clock_frequency(&self) -> Output<u32>
fn max_compute_units(&self) -> Output<u32>
fn max_constant_args(&self) -> Output<u32>
fn max_read_image_args(&self) -> Output<u32>
fn max_samplers(&self) -> Output<u32>
fn max_work_item_dimensions(&self) -> Output<u32>
fn max_write_image_args(&self) -> Output<u32>
fn mem_base_addr_align(&self) -> Output<u32>
fn min_data_type_align_size(&self) -> Output<u32>
fn native_vector_width_char(&self) -> Output<u32>
fn native_vector_width_short(&self) -> Output<u32>
fn native_vector_width_int(&self) -> Output<u32>
fn native_vector_width_long(&self) -> Output<u32>
fn native_vector_width_float(&self) -> Output<u32>
fn partition_max_sub_devices(&self) -> Output<u32>
fn preferred_vector_width_char(&self) -> Output<u32>
fn preferred_vector_width_short(&self) -> Output<u32>
fn preferred_vector_width_int(&self) -> Output<u32>
fn preferred_vector_width_long(&self) -> Output<u32>
fn preferred_vector_width_float(&self) -> Output<u32>
fn preferred_vector_width_double(&self) -> Output<u32>
fn preferred_vector_width_half(&self) -> Output<u32>
fn vendor_id(&self) -> Output<u32>
fn available(&self) -> Output<bool>
fn compiler_available(&self) -> Output<bool>
fn endian_little(&self) -> Output<bool>
fn error_correction_support(&self) -> Output<bool>
fn host_unified_memory(&self) -> Output<bool>
fn image_support(&self) -> Output<bool>
fn linker_available(&self) -> Output<bool>
fn preferred_interop_user_sync(&self) -> Output<bool>
Sourcefn name(&self) -> Output<String>
fn name(&self) -> Output<String>
Examples found in repository?
examples/ll_simple_add/main.rs (line 33)
12fn run_procedural() {
13 unsafe {
14 let src = include_str!("simple_add.ocl");
15
16 let mut platforms = list_platforms().unwrap();
17
18 if platforms.len() == 0 {
19 panic!("No platforms found!!!");
20 }
21
22 let platform = platforms.remove(0);
23 let devices = list_devices_by_type(&platform, DeviceType::ALL).unwrap();
24
25 if devices.len() == 0 {
26 panic!("No devices found!!!");
27 }
28 let context = ClContext::create(&devices[..]).unwrap();
29
30 println!("creating program...");
31 let mut program: ClProgram = ClProgram::create_with_source(&context, src).unwrap();
32
33 let names = devices.iter().map(|d| d.name().unwrap());
34 println!("building program on devices {:?}...", names);
35
36 let () = program
37 .build(&devices[..])
38 .unwrap_or_else(|e| panic!("Failed to build program {:?}", e));
39
40 for device in devices[0..1].iter() {
41 let program2 = (&program).clone();
42 let r_count = program2.reference_count().unwrap();
43 let prog_log = program2.get_log(device).unwrap();
44 let prog_src = program2.source().unwrap();
45 println!("Program log {:?} {:?}, {:?}", r_count, prog_log, prog_src);
46 println!("Device {:?}", device);
47
48 let mut command_queue: ClCommandQueue =
49 ClCommandQueue::create(&context, device, None).unwrap();
50
51 let vec_a = vec![1i64, 2, 3];
52 let vec_b = vec![0i64, -1, -2];
53
54 let len = vec_a.len();
55
56 let work: Work = Work::new(len);
57 let name = device.name().unwrap();
58 println!("{}", name);
59
60 let mut mem_a = ClMem::create::<i64, usize>(
61 &context,
62 len,
63 HostAccess::WriteOnly,
64 KernelAccess::ReadOnly,
65 MemLocation::AllocOnDevice,
66 )
67 .unwrap();
68 let mut mem_b = ClMem::create::<i64, usize>(
69 &context,
70 len,
71 HostAccess::WriteOnly,
72 KernelAccess::ReadOnly,
73 MemLocation::AllocOnDevice,
74 )
75 .unwrap();
76 let mut mem_c = ClMem::create::<i64, usize>(
77 &context,
78 len,
79 HostAccess::ReadOnly,
80 KernelAccess::WriteOnly,
81 MemLocation::AllocOnDevice,
82 )
83 .unwrap();
84 println!("Creating kernel simple_add");
85 let mut simple_add = ClKernel::create(&program2, "simple_add").unwrap();
86
87 println!("writing buffer a...");
88 let _write_event_a = command_queue
89 .write_buffer(&mut mem_a, &vec_a[..], None)
90 .unwrap();
91
92 println!("writing buffer b...");
93 let _write_event_b = command_queue
94 .write_buffer(&mut mem_b, &vec_b[..], None)
95 .unwrap();
96
97 println!("mem_a {:?}", mem_a);
98
99 println!("setting simple_add arg 0 as mem_a");
100 simple_add.set_arg(0, &mut mem_a).unwrap();
101
102 println!("setting simple_add arg 1 as mem_b");
103 simple_add.set_arg(1, &mut mem_b).unwrap();
104
105 println!("setting simple_add mut arg 2 as mem_c");
106 simple_add.set_arg(2, &mut mem_c).unwrap();
107
108 println!("calling enqueue_kernel on simple_add");
109 let event = command_queue
110 .enqueue_kernel(&mut simple_add, &work, None)
111 .unwrap();
112 let () = event.wait().unwrap();
113 println!("done putting event into WaitList...");
114 let mut vec_c = vec![0i64; len];
115
116 let _read_event = command_queue
117 .read_buffer(&mem_c, &mut vec_c[..], None)
118 .unwrap();
119
120 println!(" {}", string_from_slice(&vec_a[..]));
121 println!("+ {}", string_from_slice(&vec_b[..]));
122 println!("= {}", string_from_slice(&vec_c[..]));
123 }
124 }
125}fn opencl_c_version(&self) -> Output<String>
fn profile(&self) -> Output<String>
fn vendor(&self) -> Output<String>
fn version(&self) -> Output<String>
fn driver_version(&self) -> Output<String>
fn global_mem_cache_size(&self) -> Output<u64>
fn global_mem_size(&self) -> Output<u64>
fn local_mem_size(&self) -> Output<u64>
fn max_constant_buffer_size(&self) -> Output<u64>
fn max_mem_alloc_size(&self) -> Output<u64>
fn image2d_max_width(&self) -> Output<usize>
fn image2d_max_height(&self) -> Output<usize>
fn image3d_max_width(&self) -> Output<usize>
fn image3d_max_height(&self) -> Output<usize>
fn image3d_max_depth(&self) -> Output<usize>
fn image_max_buffer_size(&self) -> Output<usize>
fn image_max_array_size(&self) -> Output<usize>
fn max_parameter_size(&self) -> Output<usize>
fn max_work_group_size(&self) -> Output<usize>
fn printf_buffer_size(&self) -> Output<usize>
fn profiling_timer_resolution(&self) -> Output<usize>
fn max_work_item_sizes(&self) -> Output<Vec<usize>>
fn local_mem_type(&self) -> Output<DeviceLocalMemType>
fn execution_capabilities(&self) -> Output<DeviceExecCapabilities>
fn global_mem_cache_type(&self) -> Output<DeviceMemCacheType>
fn partition_affinity_domain(&self) -> Output<DeviceAffinityDomain>
fn device_type(&self) -> Output<DeviceType>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.