Skip to content

Commit

Permalink
add macro control
Browse files Browse the repository at this point in the history
  • Loading branch information
galeselee committed Oct 31, 2022
1 parent a0ec473 commit 7fd4225
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion taichi/runtime/llvm/llvm_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ std::unique_ptr<llvm::Module> TaichiLLVMContext::module_from_file(
std::unique_ptr<llvm::Module> module = module_from_bitcode_file(
fmt::format("{}/{}", runtime_lib_dir(), file), ctx);
if (arch_ == Arch::cuda || arch_ == Arch::amdgpu) {
#if defined(TI_WITH_CUDA) || defined(TI_WITH_AMDGPU)
auto patch_intrinsic = [&](std::string name, Intrinsic::ID intrin,
bool ret = true,
std::vector<llvm::Type *> types = {},
Expand Down Expand Up @@ -391,8 +392,8 @@ std::unique_ptr<llvm::Module> TaichiLLVMContext::module_from_file(
patch_atomic_add("atomic_add_i64", llvm::AtomicRMWInst::Add);
patch_atomic_add("atomic_add_f64", llvm::AtomicRMWInst::FAdd);
patch_atomic_add("atomic_add_f32", llvm::AtomicRMWInst::FAdd);
#endif


if (arch_ == Arch::cuda) {
module->setTargetTriple("nvptx64-nvidia-cuda");

Expand Down Expand Up @@ -492,6 +493,7 @@ std::unique_ptr<llvm::Module> TaichiLLVMContext::module_from_file(

if (arch_ == Arch::amdgpu) {
module->setTargetTriple("amdgcn-amd-amdhsa");
#ifdef TI_WITH_AMDGPU
for (auto &f : *module) {
f.addFnAttr("target-cpu","");
f.addFnAttr("target-features","");
Expand Down Expand Up @@ -519,6 +521,7 @@ std::unique_ptr<llvm::Module> TaichiLLVMContext::module_from_file(
}
patch_intrinsic("thread_idx", llvm::Intrinsic::amdgcn_workitem_id_x);
patch_intrinsic("block_idx", llvm::Intrinsic::amdgcn_workgroup_id_x);
#endif
}
}

Expand Down

0 comments on commit 7fd4225

Please sign in to comment.