BLD: Move config.h creation to `setup` stage

This commit is contained in:
Mateusz Sokół 2024-08-05 15:43:06 +02:00
parent 7d4b13333c
commit 84c23b5e11
11 changed files with 43 additions and 85 deletions

View File

@ -49,7 +49,7 @@ foreach lvl : ['l1', 'l2', 'l3', 'l3_3m']
executable(
op_name,
sources: mapped_sources + [config_h],
sources: mapped_sources,
link_with: [_openblas],
dependencies: [dependency('threads')],
include_directories: ctest_inc,

View File

@ -540,7 +540,7 @@ foreach conf : kernel_confs
# message(conf)
_kern_libs += [static_library(
conf['name'],
[conf['src'], config_h],
conf['src'],
include_directories: _inc,
c_args: conf['c_args'],
)]

View File

@ -465,7 +465,7 @@ foreach conf : kernel_confs
# message(conf)
_kern_libs += [static_library(
conf['name'],
[conf['src'], config_h],
conf['src'],
include_directories: _inc,
c_args: conf['c_args'],
)]

View File

@ -74,7 +74,7 @@ others_libs = []
foreach conf : others_confs
others_libs += [static_library(
conf['name'],
[conf['src'], config_h],
conf['src'],
include_directories: _inc,
c_args: conf['c_args']
)]

View File

@ -1,16 +1,9 @@
#include <stdio.h>
#ifndef BUILD_KERNEL
#ifdef BUILD_WITH_MESON
#include "_config_for_getarch_2nd.h"
#else
#include "config.h"
#endif
#else
#include "config_kernel.h"
#endif
#if (defined(__WIN32__) || defined(__WIN64__) || defined(__CYGWIN32__) || defined(__CYGWIN64__) || defined(_WIN32) || defined(_WIN64)) && defined(__64BIT__)
typedef long long BLASLONG;
typedef unsigned long long BLASULONG;

View File

@ -623,7 +623,7 @@ foreach conf : _blas_roots
# Create the static library for each symbol
lib = static_library(
sym_name,
sources: [conf['fname'], config_h],
sources: conf['fname'],
include_directories: _inc,
c_args: compiler_args + [
f'-DASMNAME=@asm_name_prefix@@sym_name@',
@ -645,7 +645,7 @@ foreach conf : _blas_roots
endif
cblas_lib = static_library(
cblas_sym_name,
sources: [conf['fname'], config_h],
sources: conf['fname'],
include_directories: _inc,
c_args: compiler_args + [
'-DCBLAS',

View File

@ -1,21 +0,0 @@
import argparse
def merge_files(file1_path: str, file2_path: str) -> str:
# Open files in read mode
with open(file1_path, 'r') as file1, open(file2_path, 'r') as file2:
content1 = file1.read()
content2 = file2.read()
merged_content = content1 + "\n" + content2
return merged_content
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Merge and print content from two text files.")
parser.add_argument("file1", help="Path to the first text file.")
parser.add_argument("file2", help="Path to the second text file.")
args = parser.parse_args()
output = merge_files(args.file1, args.file2)
print(output)

View File

@ -1509,7 +1509,7 @@ _is_asm = false
foreach conf: kernel_confs
_kern_libs += static_library(
conf['name'],
[conf['src'], config_h],
conf['src'],
include_directories: _inc,
c_args: conf['c_args'],
# See gh discussion 13374 for why, basically .S are coded as fortran..

View File

@ -462,55 +462,31 @@ symb_defs = {
# config.h file generation
_config_1_path = meson.current_build_dir() / '_config_1.h'
_join_files_py = '../join_files.py'
run_command('./c_check', 'Makefile.conf', _config_1_path, cc_id, check: true)
run_command('./f_check', 'Makefile.conf', _config_1_path, fc_id, check: true)
_config_h = meson.current_build_dir() / 'config.h'
run_command('./c_check', 'Makefile.conf', _config_h, cc_id, check: true)
run_command('./f_check', 'Makefile.conf', _config_h, fc_id, check: true)
getarch = executable('getarch', ['getarch.c', 'cpuid.S'])
run_command(cc_id, '-o', 'getarch', 'getarch.c', 'cpuid.S', check: true)
_getarch_result = run_command('./getarch', '1', check: true, capture: true)
run_command(py3,
'./write_to_file.py',
_getarch_result.stdout(),
_config_h,
check: true)
_config_2h = custom_target('_config_2h',
output: '_config_2.h',
command: [getarch, '1'],
depends: [getarch],
capture: true,
)
_config_for_getarch_2nd_h = custom_target('_config_for_getarch_2nd_h',
output: '_config_for_getarch_2nd.h',
command: [
py3,
_join_files_py,
_config_1_path,
_config_2h,
],
depends: [_config_2h],
capture: true,
)
getarch_2nd = executable('getarch_2nd',
['getarch_2nd.c', _config_for_getarch_2nd_h],
c_args: ['-DGEMM_MULTITHREAD_THRESHOLD=4', '-DBUILD_WITH_MESON']
)
_config_3h = custom_target('_config_3h',
output: '_config_3.h',
command: [getarch_2nd, '1'],
depends: [getarch_2nd],
capture: true,
)
config_h = custom_target('config_h',
output: 'config.h',
command: [
py3,
_join_files_py,
_config_for_getarch_2nd_h,
_config_3h,
],
depends: [_config_3h],
capture: true,
)
run_command(cc_id,
'-DGEMM_MULTITHREAD_THRESHOLD=4',
'-I.',
f'-I@prj_bld_dir@',
'-o', 'getarch_2nd',
'getarch_2nd.c',
capture: true, check: true)
_getarch_2nd_result = run_command('./getarch_2nd', '1', check: true, capture: true)
run_command(py3,
'./write_to_file.py',
_getarch_2nd_result.stdout(),
_config_h,
check: true)
# Ignoring other hostarch checks and conflicts for arch in BSD for now
_inc = [include_directories('.')]
@ -563,7 +539,6 @@ pcl = custom_target('prepare_config_last',
exprecision ? '--exprecision' : [],
],
build_by_default : true,
depends: config_h,
)
# Generate the headers

View File

@ -1,5 +1,4 @@
sources_utest = [
config_h,
'utest_main.c',
'test_min.c',
'test_amax.c',
@ -18,7 +17,6 @@ sources_utest = [
dir_ext = 'test_extensions'
sources_utest_ext = [
config_h,
'utest_main.c',
dir_ext / 'xerbla.c',
dir_ext / 'common.c',

13
write_to_file.py Normal file
View File

@ -0,0 +1,13 @@
import argparse
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Write contents to file.")
parser.add_argument("contents", help="Contents.")
parser.add_argument("file_path", help="File path.")
args = parser.parse_args()
f = open(args.file_path, "a")
f.write(args.contents)
f.close()