mirror of
https://github.com/vosen/ZLUDA.git
synced 2025-09-27 11:49:04 +00:00
Parse griddepcontrol
This commit is contained in:
parent
b04a206258
commit
3c56ee446c
7 changed files with 48 additions and 1 deletions
30
ptx/src/pass/filter_for_demo.rs
Normal file
30
ptx/src/pass/filter_for_demo.rs
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
pub(crate) fn run<'input>(
|
||||||
|
directives: Vec<ptx_parser::Directive<'input, ptx_parser::ParsedOperand<&'input str>>>,
|
||||||
|
) -> Vec<ptx_parser::Directive<'input, ptx_parser::ParsedOperand<&'input str>>> {
|
||||||
|
let demo_kernels_path = std::env::var("ZLUDA_DEMO_KERNELS").unwrap();
|
||||||
|
let demo_kernels_file = std::fs::read_to_string(demo_kernels_path).unwrap();
|
||||||
|
let demo_kernels = demo_kernels_file
|
||||||
|
.lines()
|
||||||
|
.map(|line| line.trim())
|
||||||
|
.filter(|line| !line.is_empty())
|
||||||
|
.collect::<std::collections::HashSet<_>>();
|
||||||
|
let result = directives
|
||||||
|
.into_iter()
|
||||||
|
.filter(|directive| match directive {
|
||||||
|
ptx_parser::Directive::Method(_, method) => {
|
||||||
|
!method.func_directive.name.is_kernel()
|
||||||
|
|| demo_kernels.contains(method.func_directive.name())
|
||||||
|
}
|
||||||
|
_ => true,
|
||||||
|
})
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
for directive in result.iter() {
|
||||||
|
match directive {
|
||||||
|
ptx_parser::Directive::Method(_, method) => {
|
||||||
|
eprintln!("{}", method.func_directive.name());
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result
|
||||||
|
}
|
|
@ -197,6 +197,7 @@ fn run_instruction<'input>(
|
||||||
| ast::Instruction::Xor { .. }
|
| ast::Instruction::Xor { .. }
|
||||||
| ast::Instruction::Vote { .. }
|
| ast::Instruction::Vote { .. }
|
||||||
| ast::Instruction::ReduxSync { .. }
|
| ast::Instruction::ReduxSync { .. }
|
||||||
|
| ast::Instruction::GridDepControl { .. }
|
||||||
| ast::Instruction::LdMatrix { .. } => result.push(Statement::Instruction(instruction)),
|
| ast::Instruction::LdMatrix { .. } => result.push(Statement::Instruction(instruction)),
|
||||||
ast::Instruction::Add {
|
ast::Instruction::Add {
|
||||||
data:
|
data:
|
||||||
|
|
|
@ -1855,6 +1855,7 @@ fn get_modes<T: ast::Operand>(inst: &ast::Instruction<T>) -> InstructionModes {
|
||||||
| ast::Instruction::AtomCas { .. }
|
| ast::Instruction::AtomCas { .. }
|
||||||
| ast::Instruction::Vote { .. }
|
| ast::Instruction::Vote { .. }
|
||||||
| ast::Instruction::ReduxSync { .. }
|
| ast::Instruction::ReduxSync { .. }
|
||||||
|
| ast::Instruction::GridDepControl { .. }
|
||||||
| ast::Instruction::LdMatrix { .. } => InstructionModes::none(),
|
| ast::Instruction::LdMatrix { .. } => InstructionModes::none(),
|
||||||
ast::Instruction::Add {
|
ast::Instruction::Add {
|
||||||
data: ast::ArithDetails::Integer(_),
|
data: ast::ArithDetails::Integer(_),
|
||||||
|
|
|
@ -522,6 +522,7 @@ impl<'a> MethodEmitContext<'a> {
|
||||||
ast::Instruction::CpAsyncCommitGroup {} => Ok(()), // nop
|
ast::Instruction::CpAsyncCommitGroup {} => Ok(()), // nop
|
||||||
ast::Instruction::CpAsyncWaitGroup { .. } => Ok(()), // nop
|
ast::Instruction::CpAsyncWaitGroup { .. } => Ok(()), // nop
|
||||||
ast::Instruction::CpAsyncWaitAll { .. } => Ok(()), // nop
|
ast::Instruction::CpAsyncWaitAll { .. } => Ok(()), // nop
|
||||||
|
ast::Instruction::GridDepControl { .. } => Ok(()), // nop
|
||||||
// replaced by a function call
|
// replaced by a function call
|
||||||
ast::Instruction::Bfe { .. }
|
ast::Instruction::Bfe { .. }
|
||||||
| ast::Instruction::Bar { .. }
|
| ast::Instruction::Bar { .. }
|
||||||
|
|
|
@ -13,6 +13,7 @@ use strum_macros::EnumIter;
|
||||||
|
|
||||||
mod deparamize_functions;
|
mod deparamize_functions;
|
||||||
mod expand_operands;
|
mod expand_operands;
|
||||||
|
mod filter_for_demo;
|
||||||
mod fix_special_registers;
|
mod fix_special_registers;
|
||||||
mod hoist_globals;
|
mod hoist_globals;
|
||||||
mod insert_explicit_load_store;
|
mod insert_explicit_load_store;
|
||||||
|
@ -65,7 +66,9 @@ pub fn to_llvm_module<'input>(
|
||||||
let mut flat_resolver = GlobalStringIdentResolver2::<'input>::new(SpirvWord(1));
|
let mut flat_resolver = GlobalStringIdentResolver2::<'input>::new(SpirvWord(1));
|
||||||
let mut scoped_resolver = ScopedResolver::new(&mut flat_resolver);
|
let mut scoped_resolver = ScopedResolver::new(&mut flat_resolver);
|
||||||
let sreg_map = SpecialRegistersMap::new(&mut scoped_resolver)?;
|
let sreg_map = SpecialRegistersMap::new(&mut scoped_resolver)?;
|
||||||
let directives = normalize_identifiers2::run(&mut scoped_resolver, ast.directives)?;
|
let directives = filter_for_demo::run(ast.directives);
|
||||||
|
on_pass_end("filter_for_demo");
|
||||||
|
let directives = normalize_identifiers2::run(&mut scoped_resolver, directives)?;
|
||||||
on_pass_end("normalize_identifiers2");
|
on_pass_end("normalize_identifiers2");
|
||||||
let directives = replace_known_functions::run(&mut flat_resolver, directives);
|
let directives = replace_known_functions::run(&mut flat_resolver, directives);
|
||||||
on_pass_end("replace_known_functions");
|
on_pass_end("replace_known_functions");
|
||||||
|
|
|
@ -721,6 +721,9 @@ ptx_parser_macros::generate_instruction_type!(
|
||||||
space: { data.state_space },
|
space: { data.state_space },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
GridDepControl {
|
||||||
|
data: crate::GridDepControlAction,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -3897,6 +3897,14 @@ derive_parser!(
|
||||||
.type: ScalarType = {.b16, .b8};
|
.type: ScalarType = {.b16, .b8};
|
||||||
// .dst_fmt = { .b8x16 };
|
// .dst_fmt = { .b8x16 };
|
||||||
// .src_fmt = { .b6x16_p32, .b4x16_p64 };
|
// .src_fmt = { .b6x16_p32, .b4x16_p64 };
|
||||||
|
|
||||||
|
// https://docs.nvidia.com/cuda/parallel-thread-execution/#parallel-synchronization-and-communication-instructions-griddepcontrol
|
||||||
|
griddepcontrol.action => {
|
||||||
|
Instruction::GridDepControl {
|
||||||
|
data: action
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.action: GridDepControlAction = { .launch_dependents, .wait };
|
||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue