[libc-commits] [libc] [libc] Compile the GPU functions with '-fconvergent-functions' (PR #70229)

Joseph Huber via libc-commits libc-commits at lists.llvm.org
Wed Oct 25 10:12:52 PDT 2023


https://github.com/jhuber6 created https://github.com/llvm/llvm-project/pull/70229

Summary:
This patch simply adds the `-fconvergent-functions` flag to the GPU
compilation. This is in relation to the behaviour of SIMT
architectures under divergence. With the flag, we assume every function
is convergent by default and rely on the compiler's divergence analysis
to transform it if possible.

Fixes: https://github.com/llvm/llvm-project/issues/63853


>From b794f42f4429fe3a3e479d8f76724cfc4361c64f Mon Sep 17 00:00:00 2001
From: Joseph Huber <jhuber6 at vols.utk.edu>
Date: Wed, 25 Oct 2023 12:09:49 -0500
Subject: [PATCH] [libc] Compile the GPU functions with
 '-fconvergent-functions'

Summary:
This patch simply adds the `-fconvergent-functions` flag to the GPU
compilation. This is in relation to the behaviour of SIMT
architectures under divergence. With the flag, we assume every function
is convergent by default and rely on the compiler's divergence analysis
to transform it if possible.

Fixes: https://github.com/llvm/llvm-project/issues/63853
---
 libc/cmake/modules/LLVMLibCObjectRules.cmake | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libc/cmake/modules/LLVMLibCObjectRules.cmake b/libc/cmake/modules/LLVMLibCObjectRules.cmake
index 7caa3b2db75dd2f..cf5097e23a20453 100644
--- a/libc/cmake/modules/LLVMLibCObjectRules.cmake
+++ b/libc/cmake/modules/LLVMLibCObjectRules.cmake
@@ -68,6 +68,7 @@ function(_get_common_compile_options output_var flags)
   if (LIBC_TARGET_ARCHITECTURE_IS_GPU)
     list(APPEND compile_options "-nogpulib")
     list(APPEND compile_options "-fvisibility=hidden")
+    list(APPEND compile_options "-fconvergent-functions")
 
     # Manually disable all standard include paths and include the resource
     # directory to prevent system headers from being included.



More information about the libc-commits mailing list