From 012e9bd9dfa01272bea67e3faea40f56c713b5de Mon Sep 17 00:00:00 2001 From: JBludau Date: Thu, 9 Feb 2023 16:26:02 +0000 Subject: [PATCH 1/4] used script wrapper to capture colored output of compile command --- pykokkos/core/cpp_setup.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pykokkos/core/cpp_setup.py b/pykokkos/core/cpp_setup.py index 44765cc3..2301c631 100644 --- a/pykokkos/core/cpp_setup.py +++ b/pykokkos/core/cpp_setup.py @@ -243,11 +243,16 @@ def invoke_script(self, output_dir: Path, space: ExecutionSpace, enable_uvm: boo compute_capability, # Device compute capability lib_suffix, # The libkokkos* suffix identifying the gpu str(compiler_path)] # The path to the compiler to use - compile_result = subprocess.run(command, cwd=output_dir, capture_output=True, check=False) + + if True: + command = [string if string != '' else "' '" for string in command] + command: Str = "script --log-io compile.out --return --command " + "\""+" ".join(command) + "\"" + + compile_result = subprocess.run(command, cwd=output_dir, capture_output=True, check=False, shell=True) if compile_result.returncode != 0: print(compile_result.stderr.decode("utf-8")) - print(f"C++ compilation in {output_dir} failed") + print(f"C++ compilation in {output_dir} failed. For colored compiler output run 'cat {output_dir}/compile.out'") sys.exit(1) patchelf: List[str] = ["patchelf", From c1be48b14759bd7418f1086f988bfb49351da209 Mon Sep 17 00:00:00 2001 From: JBludau Date: Mon, 13 Mar 2023 10:44:49 +0000 Subject: [PATCH 2/4] changed check for compiled module to check for .so file --- pykokkos/core/cpp_setup.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pykokkos/core/cpp_setup.py b/pykokkos/core/cpp_setup.py index 2301c631..07c8c751 100644 --- a/pykokkos/core/cpp_setup.py +++ b/pykokkos/core/cpp_setup.py @@ -328,10 +328,14 @@ def get_cuda_compute_capability(self, compiler: str) -> str: @staticmethod def is_compiled(output_dir: Path) -> bool: """ - Check if an entity is compiled + Check if an entity is compiled. It does this via checking if any .so file exists. :param output_dir: the directory containing the compiled entity - :returns: true if compiled + :returns: true if any .so object exists """ + so_files = output_dir.glob("*.so") + contains_so_files = False + for file in so_files: + contains_so_files = file.is_file() - return output_dir.is_dir() + return contains_so_files From d24a3719bca3be6bf9039362091aaaba05c3e6d2 Mon Sep 17 00:00:00 2001 From: JBludau Date: Mon, 13 Mar 2023 13:42:11 +0000 Subject: [PATCH 3/4] corrected empty argument to be really empty and not a single whitespace --- pykokkos/core/cpp_setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pykokkos/core/cpp_setup.py b/pykokkos/core/cpp_setup.py index 07c8c751..7875f82a 100644 --- a/pykokkos/core/cpp_setup.py +++ b/pykokkos/core/cpp_setup.py @@ -245,7 +245,7 @@ def invoke_script(self, output_dir: Path, space: ExecutionSpace, enable_uvm: boo str(compiler_path)] # The path to the compiler to use if True: - command = [string if string != '' else "' '" for string in command] + command = [string if string != '' else "''" for string in command] command: Str = "script --log-io compile.out --return --command " + "\""+" ".join(command) + "\"" compile_result = subprocess.run(command, cwd=output_dir, capture_output=True, check=False, shell=True) From d4719605390f719b79e12c237ea6658e0b34aede Mon Sep 17 00:00:00 2001 From: JBludau Date: Mon, 13 Mar 2023 13:48:06 +0000 Subject: [PATCH 4/4] restricted colored output to linux machines for now --- pykokkos/core/cpp_setup.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pykokkos/core/cpp_setup.py b/pykokkos/core/cpp_setup.py index 7875f82a..36edc9a4 100644 --- a/pykokkos/core/cpp_setup.py +++ b/pykokkos/core/cpp_setup.py @@ -244,7 +244,8 @@ def invoke_script(self, output_dir: Path, space: ExecutionSpace, enable_uvm: boo lib_suffix, # The libkokkos* suffix identifying the gpu str(compiler_path)] # The path to the compiler to use - if True: + if sys.platform == "linux" or sys.platform == "linux2": + #on linux we can color the output otherwise this is not implemented command = [string if string != '' else "''" for string in command] command: Str = "script --log-io compile.out --return --command " + "\""+" ".join(command) + "\"" @@ -252,7 +253,7 @@ def invoke_script(self, output_dir: Path, space: ExecutionSpace, enable_uvm: boo if compile_result.returncode != 0: print(compile_result.stderr.decode("utf-8")) - print(f"C++ compilation in {output_dir} failed. For colored compiler output run 'cat {output_dir}/compile.out'") + print(f"C++ compilation in {output_dir} failed. For colored compiler output (on linux) run 'cat {output_dir}/compile.out'") sys.exit(1) patchelf: List[str] = ["patchelf",