Browse Source

Merge pull request #16 from HaoZeke/setup-config-h

BLD: Move config.h creation to `setup` stage
pull/4885/head
Rohit Goswami GitHub 1 year ago
parent
commit
dfa1e8f8f3
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
11 changed files with 45 additions and 87 deletions
  1. +1
    -1
      ctest/meson.build
  2. +1
    -1
      driver/level2/meson.build
  3. +1
    -1
      driver/level3/meson.build
  4. +1
    -1
      driver/others/meson.build
  5. +0
    -7
      getarch_2nd.c
  6. +2
    -2
      interface/meson.build
  7. +0
    -21
      join_files.py
  8. +1
    -1
      kernel/meson.build
  9. +25
    -50
      meson.build
  10. +0
    -2
      utest/meson.build
  11. +13
    -0
      write_to_file.py

+ 1
- 1
ctest/meson.build 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,


+ 1
- 1
driver/level2/meson.build 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'],
)]


+ 1
- 1
driver/level3/meson.build 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'],
)]


+ 1
- 1
driver/others/meson.build 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']
)]


+ 0
- 7
getarch_2nd.c 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;


+ 2
- 2
interface/meson.build 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',


+ 0
- 21
join_files.py 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)

+ 1
- 1
kernel/meson.build 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..


+ 25
- 50
meson.build 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)

getarch = executable('getarch', ['getarch.c', 'cpuid.S'])

_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,
)
_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)

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)

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


+ 0
- 2
utest/meson.build 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
- 0
write_to_file.py 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()

Loading…
Cancel
Save