mirror of
https://github.com/vosen/ZLUDA.git
synced 2025-04-28 21:47:57 +03:00
Simplify compilation, make sure linking ockl works with floating point mode
This commit is contained in:
parent
2a8e167341
commit
9b7a685173
1 changed files with 24 additions and 24 deletions
|
@ -133,21 +133,26 @@ pub fn compile_bitcode(
|
||||||
&linking_info,
|
&linking_info,
|
||||||
amd_comgr_action_kind_t::AMD_COMGR_ACTION_LINK_BC_TO_BC,
|
amd_comgr_action_kind_t::AMD_COMGR_ACTION_LINK_BC_TO_BC,
|
||||||
)?;
|
)?;
|
||||||
let link_with_device_libs_info = ActionInfo::new()?;
|
let compile_to_exec = ActionInfo::new()?;
|
||||||
link_with_device_libs_info.set_isa_name(gcn_arch)?;
|
compile_to_exec.set_isa_name(gcn_arch)?;
|
||||||
link_with_device_libs_info.set_language(amd_comgr_language_t::AMD_COMGR_LANGUAGE_LLVM_IR)?;
|
compile_to_exec.set_language(amd_comgr_language_t::AMD_COMGR_LANGUAGE_LLVM_IR)?;
|
||||||
// This makes no sense, but it makes ockl linking work
|
let common_options = [
|
||||||
link_with_device_libs_info
|
// This makes no sense, but it makes ockl linking work
|
||||||
.set_options([c"-Xclang", c"-mno-link-builtin-bitcode-postopt"].into_iter())?;
|
c"-Xclang",
|
||||||
let with_device_libs = do_action(
|
c"-mno-link-builtin-bitcode-postopt",
|
||||||
&linked_data_set,
|
// Otherwise LLVM omits dynamic fp mode for ockl functions during linking
|
||||||
&link_with_device_libs_info,
|
// and then fails to inline them
|
||||||
amd_comgr_action_kind_t::AMD_COMGR_ACTION_COMPILE_SOURCE_WITH_DEVICE_LIBS_TO_BC,
|
c"-Xclang",
|
||||||
)?;
|
c"-fdenormal-fp-math=dynamic",
|
||||||
let compile_action_info = ActionInfo::new()?;
|
c"-O3",
|
||||||
compile_action_info.set_isa_name(gcn_arch)?;
|
c"-mno-wavefrontsize64",
|
||||||
let common_options = [c"-O3", c"-mno-wavefrontsize64", c"-mcumode"].into_iter();
|
c"-mcumode",
|
||||||
|
// Useful for inlining reports, combined with AMD_COMGR_SAVE_TEMPS=1 AMD_COMGR_EMIT_VERBOSE_LOGS=1 AMD_COMGR_REDIRECT_LOGS=stderr
|
||||||
|
// c"-fsave-optimization-record=yaml",
|
||||||
|
]
|
||||||
|
.into_iter();
|
||||||
let opt_options = if cfg!(debug_assertions) {
|
let opt_options = if cfg!(debug_assertions) {
|
||||||
|
//[c"-g", c"-mllvm", c"-print-before-all", c"", c""]
|
||||||
[c"-g", c"", c"", c"", c""]
|
[c"-g", c"", c"", c"", c""]
|
||||||
} else {
|
} else {
|
||||||
[
|
[
|
||||||
|
@ -159,19 +164,14 @@ pub fn compile_bitcode(
|
||||||
c"-inlinehint-threshold=3250",
|
c"-inlinehint-threshold=3250",
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
compile_action_info.set_options(common_options.chain(opt_options))?;
|
compile_to_exec.set_options(common_options.chain(opt_options))?;
|
||||||
let reloc_data_set = do_action(
|
|
||||||
&with_device_libs,
|
|
||||||
&compile_action_info,
|
|
||||||
amd_comgr_action_kind_t::AMD_COMGR_ACTION_CODEGEN_BC_TO_RELOCATABLE,
|
|
||||||
)?;
|
|
||||||
let exec_data_set = do_action(
|
let exec_data_set = do_action(
|
||||||
&reloc_data_set,
|
&linked_data_set,
|
||||||
&compile_action_info,
|
&compile_to_exec,
|
||||||
amd_comgr_action_kind_t::AMD_COMGR_ACTION_LINK_RELOCATABLE_TO_EXECUTABLE,
|
amd_comgr_action_kind_t::AMD_COMGR_ACTION_COMPILE_SOURCE_TO_EXECUTABLE,
|
||||||
)?;
|
)?;
|
||||||
let executable =
|
let executable =
|
||||||
exec_data_set.get_data(amd_comgr_data_kind_t::AMD_COMGR_DATA_KIND_EXECUTABLE, 0)?;
|
exec_data_set.get_data(amd_comgr_data_kind_t::AMD_COMGR_DATA_KIND_EXECUTABLE, 0)?;
|
||||||
executable.copy_content()
|
executable.copy_content()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue