From 226a9dff841a6debd632bff04443cb64f6fc44d6 Mon Sep 17 00:00:00 2001 From: Nathanne Isip Date: Wed, 23 Oct 2024 06:35:08 +0800 Subject: [PATCH] Updated build script for standard library generation for CUDA version. --- build.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/build.py b/build.py index a2bbaa6..189e737 100644 --- a/build.py +++ b/build.py @@ -112,8 +112,7 @@ lib_build_args = [ COMPILER, '-Iinclude', '-Ilib', '-shared', '-o', - lib_bin, - rt_bin + lib_bin, rt_bin ] exe_build_args += cpp_files + ['-o', OUTPUT_EXECUTABLE + '-omp'] @@ -127,9 +126,28 @@ cuda_build_args.append('-Xcompiler') cuda_build_args.append('/std:c++17') + lib_build_args = lib_build_args + [ + '-pipe', '-Ofast', '-s', + '-std=c++17', '-fopenmp', + '-msse', '-msse2', '-msse3', + '-mfpmath=sse', + '-march=native' + ] + cuda_build_args.append('-Iinclude') cuda_build_args += cpp_files + ['-o', OUTPUT_EXECUTABLE + '-nvidia'] +cuda_lib_args = [ + 'nvcc', '-Ilib', '-shared', '-o', + os.path.join('dist', 'stdzhv1.0-cuda'), + rt_bin, cc_files +] + +if PLATFORM == 'Windows': + cuda_lib_args[4] += '.dll' +else: + cuda_lib_args[4] += '.so' + try: os.makedirs(OUT_DIR, exist_ok=True) if PLATFORM == 'Windows': @@ -164,6 +182,10 @@ print(' '.join(cuda_build_args)) subprocess.run(cuda_build_args, check=True) + print("Executing:") + print(' '.join(cuda_lib_args)) + subprocess.run(cuda_lib_args, check=True) + except Exception as e: print(f"Compilation failed with error: {e}")