From 3b8ac0ee144f401baf9339d7ef1b1e7755f896a1 Mon Sep 17 00:00:00 2001 From: Valentin Churavy Date: Sat, 29 Apr 2023 19:34:10 -0400 Subject: [PATCH 1/2] Implement jl_cpu_pause on PPC64 --- src/julia_threads.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/julia_threads.h b/src/julia_threads.h index 29f152172d2ab..6f3f768b16e05 100644 --- a/src/julia_threads.h +++ b/src/julia_threads.h @@ -300,6 +300,10 @@ JL_DLLEXPORT void *jl_get_ptls_states(void); # define jl_cpu_pause() __asm__ volatile ("wfe" ::: "memory") # define jl_cpu_wake() __asm__ volatile ("sev" ::: "memory") # define JL_CPU_WAKE_NOOP 0 +#elif defined(_CPU_PPC64_) +# define jl_cpu_pause() __asm__ volatile ("or 27,27,27" ::: "memory") +# define jl_cpu_wake() ((void)0) +# define JL_CPU_WAKE_NOOP 1 #else # define jl_cpu_pause() ((void)0) # define jl_cpu_wake() ((void)0) From 676fe389d1969bb4347cba4456e55e51f449922e Mon Sep 17 00:00:00 2001 From: Valentin Churavy Date: Sat, 29 Apr 2023 19:39:27 -0400 Subject: [PATCH 2/2] fixup! Implement jl_cpu_pause on PPC64 --- src/ccall.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ccall.cpp b/src/ccall.cpp index e490f4146cad2..a1859a02295e2 100644 --- a/src/ccall.cpp +++ b/src/ccall.cpp @@ -1534,6 +1534,12 @@ static jl_cgval_t emit_ccall(jl_codectx_t &ctx, jl_value_t **args, size_t nargs) ctx.builder.CreateCall(pauseinst); JL_GC_POP(); return ghostValue(ctx, jl_nothing_type); + } else if (ctx.emission_context.TargetTriple.isPPC64()) { + auto hintinst = InlineAsm::get(FunctionType::get(getVoidTy(ctx.builder.getContext()), false), "or 27,27,27", + "~{memory}", true); + ctx.builder.CreateCall(hintinst); + JL_GC_POP(); + return ghostValue(ctx, jl_nothing_type); } else if (ctx.emission_context.TargetTriple.isAArch64() || (ctx.emission_context.TargetTriple.isARM() && ctx.emission_context.TargetTriple.getSubArch() != Triple::SubArchType::NoSubArch