Browse Source

BLD: Generate config.h file

pull/4832/head
Mateusz Sokół 1 year ago
parent
commit
a5ac9e7f1a
9 changed files with 92 additions and 34 deletions
  1. +1
    -1
      driver/level2/meson.build
  2. +1
    -1
      driver/level3/meson.build
  3. +1
    -1
      driver/others/meson.build
  4. +7
    -0
      getarch_2nd.c
  5. +2
    -2
      interface/meson.build
  6. +21
    -0
      join_files.py
  7. +1
    -1
      kernel/meson.build
  8. +4
    -3
      lapack-netlib/meson.build
  9. +54
    -25
      meson.build

+ 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'],
[conf['src'], config_h],
include_directories: _inc,
c_args: conf['c_args'],
)]


+ 1
- 1
driver/level3/meson.build View File

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


+ 1
- 1
driver/others/meson.build View File

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


+ 7
- 0
getarch_2nd.c View File

@@ -1,9 +1,16 @@
#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

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


+ 21
- 0
join_files.py View File

@@ -0,0 +1,21 @@
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

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


+ 4
- 3
lapack-netlib/meson.build View File

@@ -1,8 +1,9 @@
add_languages('fortran', native: false)
ff = meson.get_compiler('fortran')
if ff.has_argument('-Wno-conversion')
add_project_arguments('-Wno-conversion', language: 'fortran')
endif
# TODO(mtsokol): make it a local setting
# if ff.has_argument('-Wno-conversion')
# add_project_arguments('-Wno-conversion', language: 'fortran')
# endif

lapack_major_version = 3 # soversion
lapack_minor_version = 12


+ 54
- 25
meson.build View File

@@ -11,7 +11,7 @@
#
# NOTE: This is still a work in progress, the Makefiles are canonical
project('OpenBLAS', ['c', 'fortran'],
default_options: ['c_std=c99', 'pkg.relocatable=true'],
default_options: ['c_std=c99', 'pkgconfig.relocatable=true'],
version: '0.3.26.dev')

openblas_major_version = 0 # soversion
@@ -22,6 +22,7 @@ openblas_version = f'@openblas_major_version@.@openblas_minor_version@.@openblas
# Skip the check for valid CC
cc = meson.get_compiler('c')
fc = meson.get_compiler('fortran')
cc_id = cc.get_id()
fc_id = fc.get_id()

# Common args
@@ -67,18 +68,6 @@ else
no_affinity = false
endif

# Makefile.prebuild stuff
# TODO: Handle cpuidemu, and the target flags
# getarch = executable('getarch',
# ['getarch.c', 'cpuid.S'])
# getarch_two = executable('getarch_2nd',
# ['getarch_2nd.c'])
# config_h = custom_target('gen_config_h',
# # input: ['getarch.c'],
# output: ['config.h'],
# command: [getarch, '3']
# )

_check_prefix = []
conf_data = configuration_data()
is_win = host_machine.system() == 'windows' or host_machine.system() == 'cygwin'
@@ -115,18 +104,6 @@ endforeach
configure_file(output : 'getarch_conf.h',
configuration : conf_data)

# run_target('generate_config_h',
# command: [meson.current_build_dir() + '/getarch', '1'],
# depends: getarch)

# gch = run_command(meson.current_build_dir() + '/getarch', '1')
# outp = gch.stdout().strip()

# conf_data = configuration_data()
# configure_file(input : meson.current_build_dir() + '/config.h',
# output : 'config.h',
# configuration : conf_data)

# Makefile.system
cpu_fam = target_machine.cpu_family()

@@ -437,6 +414,58 @@ symb_defs = {
'cblas_?dotc_sub': {'def': ['CBLAS', 'FORCE_USE_STACK', 'CONJ']},
}

# 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: [
find_program('python'),
_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: [
find_program('python'),
_join_files_py,
_config_for_getarch_2nd_h,
_config_3h,
],
depends: [_config_3h],
capture: true,
)

# Ignoring other hostarch checks and conflicts for arch in BSD for now
_inc = [include_directories('.')]
subdir('lapack-netlib')


Loading…
Cancel
Save