mirror of
https://github.com/vosen/ZLUDA.git
synced 2025-07-28 20:08:39 +00:00
Fix more failing tests
This commit is contained in:
parent
340ad86d56
commit
7a45b44854
3 changed files with 67 additions and 27 deletions
|
@ -26,6 +26,15 @@ pub(crate) fn run(
|
||||||
src: src_reg,
|
src: src_reg,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
ast::Instruction::Call { data, arguments } => {
|
||||||
|
let resolver = fn_defs.get_fn_sig_resolver(arguments.func)?;
|
||||||
|
let resolved_call = resolver.resolve_in_spirv_repr(data, arguments)?;
|
||||||
|
let mut visitor = VectorRepackVisitor::new(&mut result, id_defs);
|
||||||
|
let reresolved_call =
|
||||||
|
Statement::Instruction(ast::visit_map(resolved_call, &mut visitor)?);
|
||||||
|
visitor.func.push(reresolved_call);
|
||||||
|
visitor.func.extend(visitor.post_stmts);
|
||||||
|
}
|
||||||
inst => {
|
inst => {
|
||||||
let mut visitor = VectorRepackVisitor::new(&mut result, id_defs);
|
let mut visitor = VectorRepackVisitor::new(&mut result, id_defs);
|
||||||
let instruction = Statement::Instruction(ast::visit_map(inst, &mut visitor)?);
|
let instruction = Statement::Instruction(ast::visit_map(inst, &mut visitor)?);
|
||||||
|
|
|
@ -668,57 +668,56 @@ impl<'input> FnSigMapper<'input> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
fn resolve_in_spirv_repr(
|
fn resolve_in_spirv_repr(
|
||||||
&self,
|
&self,
|
||||||
call_inst: ast::CallInst<NormalizedArgParams>,
|
data: ast::CallDetails,
|
||||||
) -> Result<ResolvedCall<NormalizedArgParams>, TranslateError> {
|
arguments: ast::CallArgs<ast::ParsedOperand<SpirvWord>>,
|
||||||
|
) -> Result<ast::Instruction<ast::ParsedOperand<SpirvWord>>, TranslateError> {
|
||||||
let func_decl = (*self.func_decl).borrow();
|
let func_decl = (*self.func_decl).borrow();
|
||||||
let mut return_arguments = Vec::new();
|
let mut data_return = Vec::new();
|
||||||
let mut input_arguments = call_inst
|
let mut arguments_return = Vec::new();
|
||||||
.param_list
|
let mut data_input = data.input_arguments;
|
||||||
.into_iter()
|
let mut arguments_input = arguments.input_arguments;
|
||||||
.zip(func_decl.input_arguments.iter())
|
|
||||||
.map(|(id, var)| (id, var.v_type.clone(), var.state_space))
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
let mut func_decl_return_iter = func_decl.return_arguments.iter();
|
let mut func_decl_return_iter = func_decl.return_arguments.iter();
|
||||||
let mut func_decl_input_iter = func_decl.input_arguments[input_arguments.len()..].iter();
|
let mut func_decl_input_iter = func_decl.input_arguments[arguments_input.len()..].iter();
|
||||||
for (idx, id) in call_inst.ret_params.iter().enumerate() {
|
for (idx, id) in arguments.return_arguments.iter().enumerate() {
|
||||||
let stays_as_return = match self.return_param_args.get(idx) {
|
let stays_as_return = match self.return_param_args.get(idx) {
|
||||||
Some(x) => *x,
|
Some(x) => *x,
|
||||||
None => return Err(TranslateError::MismatchedType),
|
None => return Err(TranslateError::MismatchedType),
|
||||||
};
|
};
|
||||||
if stays_as_return {
|
if stays_as_return {
|
||||||
if let Some(var) = func_decl_return_iter.next() {
|
if let Some(var) = func_decl_return_iter.next() {
|
||||||
return_arguments.push((*id, var.v_type.clone(), var.state_space));
|
data_return.push((var.v_type.clone(), var.state_space));
|
||||||
|
arguments_return.push(*id);
|
||||||
} else {
|
} else {
|
||||||
return Err(TranslateError::MismatchedType);
|
return Err(TranslateError::MismatchedType);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if let Some(var) = func_decl_input_iter.next() {
|
if let Some(var) = func_decl_input_iter.next() {
|
||||||
input_arguments.push((
|
data_input.push((var.v_type.clone(), var.state_space));
|
||||||
ast::Operand::Reg(*id),
|
arguments_input.push(ast::ParsedOperand::Reg(*id));
|
||||||
var.v_type.clone(),
|
|
||||||
var.state_space,
|
|
||||||
));
|
|
||||||
} else {
|
} else {
|
||||||
return Err(TranslateError::MismatchedType);
|
return Err(TranslateError::MismatchedType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if return_arguments.len() != func_decl.return_arguments.len()
|
if arguments_return.len() != func_decl.return_arguments.len()
|
||||||
|| input_arguments.len() != func_decl.input_arguments.len()
|
|| arguments_input.len() != func_decl.input_arguments.len()
|
||||||
{
|
{
|
||||||
return Err(TranslateError::MismatchedType);
|
return Err(TranslateError::MismatchedType);
|
||||||
}
|
}
|
||||||
Ok(ResolvedCall {
|
let data = ast::CallDetails {
|
||||||
return_arguments,
|
uniform: data.uniform,
|
||||||
input_arguments,
|
return_arguments: data_return,
|
||||||
uniform: call_inst.uniform,
|
input_arguments: data_input,
|
||||||
name: call_inst.func,
|
};
|
||||||
})
|
let arguments = ast::CallArgs {
|
||||||
|
func: arguments.func,
|
||||||
|
return_arguments: arguments_return,
|
||||||
|
input_arguments: arguments_input,
|
||||||
|
};
|
||||||
|
Ok(ast::Instruction::Call { data, arguments })
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Statement<I, P: ast::Operand> {
|
enum Statement<I, P: ast::Operand> {
|
||||||
|
|
|
@ -1663,6 +1663,38 @@ derive_parser!(
|
||||||
RawLdStQualifier = { .weak, .volatile };
|
RawLdStQualifier = { .weak, .volatile };
|
||||||
StateSpace = { .global };
|
StateSpace = { .global };
|
||||||
|
|
||||||
|
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-ld-global-nc
|
||||||
|
ld.global{.cop}.nc{.level::eviction_priority}{.level::cache_hint}{.level::prefetch_size}{.vec}.type d, [a]{, cache_policy} => {
|
||||||
|
if cop.is_some() && level_eviction_priority.is_some() {
|
||||||
|
state.errors.push(PtxError::SyntaxError);
|
||||||
|
}
|
||||||
|
if level_eviction_priority.is_some() || level_cache_hint || level_prefetch_size.is_some() || cache_policy.is_some() {
|
||||||
|
state.errors.push(PtxError::Todo);
|
||||||
|
}
|
||||||
|
Instruction::Ld {
|
||||||
|
data: LdDetails {
|
||||||
|
qualifier: ast::LdStQualifier::Weak,
|
||||||
|
state_space: global,
|
||||||
|
caching: cop.unwrap_or(RawLdCacheOperator::Ca).into(),
|
||||||
|
typ: Type::maybe_vector(vec, type_),
|
||||||
|
non_coherent: true
|
||||||
|
},
|
||||||
|
arguments: LdArgs { dst:d, src:a }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.cop: RawLdCacheOperator = { .ca, .cg, .cs };
|
||||||
|
.level::eviction_priority: EvictionPriority =
|
||||||
|
{ .L1::evict_normal, .L1::evict_unchanged,
|
||||||
|
.L1::evict_first, .L1::evict_last, .L1::no_allocate};
|
||||||
|
.level::cache_hint = { .L2::cache_hint };
|
||||||
|
.level::prefetch_size: PrefetchSize = { .L2::64B, .L2::128B, .L2::256B };
|
||||||
|
.vec: VectorPrefix = { .v2, .v4 };
|
||||||
|
.type: ScalarType = { .b8, .b16, .b32, .b64, .b128,
|
||||||
|
.u8, .u16, .u32, .u64,
|
||||||
|
.s8, .s16, .s32, .s64,
|
||||||
|
.f32, .f64 };
|
||||||
|
StateSpace = { .global };
|
||||||
|
|
||||||
// https://docs.nvidia.com/cuda/parallel-thread-execution/#integer-arithmetic-instructions-add
|
// https://docs.nvidia.com/cuda/parallel-thread-execution/#integer-arithmetic-instructions-add
|
||||||
add.type d, a, b => {
|
add.type d, a, b => {
|
||||||
Instruction::Add {
|
Instruction::Add {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue