aboutsummaryrefslogtreecommitdiffhomepage
path: root/ptx
diff options
context:
space:
mode:
authorAndrzej Janik <[email protected]>2020-08-28 22:37:16 +0200
committerAndrzej Janik <[email protected]>2020-08-28 22:37:16 +0200
commit34dc149be1cc83ecd931c0da742befe3eb67feaf (patch)
tree7a827c51c8ec87f0a234ce4b9e80cb2d6e8c9b0c /ptx
parentd47cd1e133995a08af15edd23c476ebf6d5cabf8 (diff)
downloadZLUDA-34dc149be1cc83ecd931c0da742befe3eb67feaf.tar.gz
ZLUDA-34dc149be1cc83ecd931c0da742befe3eb67feaf.zip
Update level0 to 1.0 and unpack fatbins
Diffstat (limited to 'ptx')
-rw-r--r--ptx/src/test/spirv_run/mod.rs59
-rw-r--r--ptx/src/translate.rs15
2 files changed, 33 insertions, 41 deletions
diff --git a/ptx/src/test/spirv_run/mod.rs b/ptx/src/test/spirv_run/mod.rs
index c159280..7de2c54 100644
--- a/ptx/src/test/spirv_run/mod.rs
+++ b/ptx/src/test/spirv_run/mod.rs
@@ -100,34 +100,37 @@ fn run_spirv<T: From<u8> + ze::SafeRepr + Copy + Debug>(
)
};
let mut result = vec![0u8.into(); output.len()];
- let mut drivers = ze::Driver::get()?;
- let drv = drivers.drain(0..1).next().unwrap();
- let mut devices = drv.devices()?;
- let dev = devices.drain(0..1).next().unwrap();
- let queue = ze::CommandQueue::new(&dev)?;
- let module = ze::Module::new_spirv(&dev, byte_il, None)?;
- let mut kernel = ze::Kernel::new_resident(&module, name)?;
- kernel.set_attribute_bool(
- ze::sys::ze_kernel_attribute_t::ZE_KERNEL_ATTR_INDIRECT_DEVICE_ACCESS,
- true,
- )?;
- let mut inp_b = ze::DeviceBuffer::<T>::new(&drv, &dev, input.len())?;
- let mut out_b = ze::DeviceBuffer::<T>::new(&drv, &dev, output.len())?;
- let inp_b_ptr_mut: ze::BufferPtrMut<T> = (&mut inp_b).into();
- let event_pool = ze::EventPool::new(&drv, 3, Some(&[&dev]))?;
- let ev0 = ze::Event::new(&event_pool, 0)?;
- let ev1 = ze::Event::new(&event_pool, 1)?;
- let ev2 = ze::Event::new(&event_pool, 2)?;
- let mut cmd_list = ze::CommandList::new(&dev)?;
- let out_b_ptr_mut: ze::BufferPtrMut<T> = (&mut out_b).into();
- cmd_list.append_memory_copy(inp_b_ptr_mut, input, None, Some(&ev0))?;
- cmd_list.append_memory_fill(out_b_ptr_mut, 0u8.into(), Some(&ev1))?;
- kernel.set_group_size(1, 1, 1)?;
- kernel.set_arg_buffer(0, inp_b_ptr_mut)?;
- kernel.set_arg_buffer(1, out_b_ptr_mut)?;
- cmd_list.append_launch_kernel(&kernel, &[1, 1, 1], Some(&ev2), &[&ev0, &ev1])?;
- cmd_list.append_memory_copy(result.as_mut_slice(), out_b_ptr_mut, None, Some(&ev2))?;
- queue.execute(cmd_list)?;
+ {
+ let mut drivers = ze::Driver::get()?;
+ let drv = drivers.drain(0..1).next().unwrap();
+ let mut ctx = ze::Context::new(&drv)?;
+ let mut devices = drv.devices()?;
+ let dev = devices.drain(0..1).next().unwrap();
+ let queue = ze::CommandQueue::new(&mut ctx, &dev)?;
+ let module = ze::Module::new_spirv(&mut ctx, &dev, byte_il, None)?;
+ let mut kernel = ze::Kernel::new_resident(&module, name)?;
+ kernel.set_indirect_access(
+ ze::sys::ze_kernel_indirect_access_flags_t::ZE_KERNEL_INDIRECT_ACCESS_FLAG_DEVICE,
+ )?;
+ let mut inp_b = ze::DeviceBuffer::<T>::new(&mut ctx, &dev, input.len())?;
+ let mut out_b = ze::DeviceBuffer::<T>::new(&mut ctx, &dev, output.len())?;
+ let inp_b_ptr_mut: ze::BufferPtrMut<T> = (&mut inp_b).into();
+ let event_pool = ze::EventPool::new(&mut ctx, 3, Some(&[&dev]))?;
+ let ev0 = ze::Event::new(&event_pool, 0)?;
+ let ev1 = ze::Event::new(&event_pool, 1)?;
+ let mut ev2 = ze::Event::new(&event_pool, 2)?;
+ let mut cmd_list = ze::CommandList::new(&mut ctx, &dev)?;
+ let out_b_ptr_mut: ze::BufferPtrMut<T> = (&mut out_b).into();
+ let mut init_evs = [ev0, ev1];
+ cmd_list.append_memory_copy(inp_b_ptr_mut, input, Some(&mut init_evs[0]), &mut [])?;
+ cmd_list.append_memory_fill(out_b_ptr_mut, 0, Some(&mut init_evs[1]), &mut [])?;
+ kernel.set_group_size(1, 1, 1)?;
+ kernel.set_arg_buffer(0, inp_b_ptr_mut)?;
+ kernel.set_arg_buffer(1, out_b_ptr_mut)?;
+ cmd_list.append_launch_kernel(&kernel, &[1, 1, 1], Some(&mut ev2), &mut init_evs)?;
+ cmd_list.append_memory_copy(result.as_mut_slice(), out_b_ptr_mut, None, &mut [ev2])?;
+ queue.execute(cmd_list)?;
+ }
Ok(result)
}
diff --git a/ptx/src/translate.rs b/ptx/src/translate.rs
index ebce1dd..c0cdf01 100644
--- a/ptx/src/translate.rs
+++ b/ptx/src/translate.rs
@@ -121,19 +121,10 @@ impl TypeWordMap {
})
}
- fn get_or_add_extended(
- &mut self,
- b: &mut dr::Builder,
- t: ast::ExtendedScalarType,
- ) -> spirv::Word {
- let key: SpirvScalarKey = t.into();
- self.get_or_add_spirv_scalar(b, key)
- }
-
fn get_or_add(&mut self, b: &mut dr::Builder, t: SpirvType) -> spirv::Word {
match t {
SpirvType::Base(key) => self.get_or_add_spirv_scalar(b, key),
- SpirvType::Pointer(typ, mut storage) => {
+ SpirvType::Pointer(typ, storage) => {
let base = self.get_or_add_spirv_scalar(b, typ);
*self
.complex
@@ -728,7 +719,7 @@ fn emit_function_body_ops(
builder.shift_left_logical(result_type, Some(a.dst), a.src1, a.src2)?;
}
ast::Instruction::Cvt(dets, arg) => {
- emit_cvt(builder, map, opencl, dets, arg)?;
+ emit_cvt(builder, map, dets, arg)?;
}
ast::Instruction::Cvta(_, arg) => {
// This would be only meaningful if const/slm/global pointers
@@ -754,7 +745,6 @@ fn emit_function_body_ops(
fn emit_cvt(
builder: &mut dr::Builder,
map: &mut TypeWordMap,
- opencl: spirv::Word,
dets: &ast::CvtDetails,
arg: &ast::Arg2<ExpandedArgParams>,
) -> Result<(), dr::Error> {
@@ -841,7 +831,6 @@ fn emit_cvt(
builder.bitcast(result_type, Some(arg.dst), src)?;
}
}
- _ => todo!(),
}
Ok(())
}