Skip to content

Commit

Permalink
ENH: Add openblas wrap
Browse files Browse the repository at this point in the history
Co-authored-by: mtsokol <[email protected]>
Co-authored-by: rgommers <[email protected]>
  • Loading branch information
3 people authored and jpakkane committed Nov 3, 2024
1 parent 0150cf0 commit bdb5dbe
Show file tree
Hide file tree
Showing 39 changed files with 7,469 additions and 0 deletions.
22 changes: 22 additions & 0 deletions ci_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,28 @@
"nowide:tests=true"
]
},
"openblas": {
"_comment": "Doesn't work with windows native compilers",
"build_on": {
"windows": false
},
"alpine_packages": [
"gfortran"
],
"brew_packages": [
"coreutils",
"gfortran"
],
"debian_packages": [
"libtinfo5",
"gfortran"
],
"msys_packages": [
"base-devel",
"mingw-w64-ucrt-x86_64-toolchain",
"mingw-w64-ucrt-x86_64-fc"
]
},
"openh264": {
"alpine_packages": [
"nasm"
Expand Down
8 changes: 8 additions & 0 deletions releases.json
Original file line number Diff line number Diff line change
Expand Up @@ -2701,6 +2701,14 @@
"1.21.0-1"
]
},
"openblas": {
"dependency_names": [
"openblas"
],
"versions": [
"0.3.28-1"
]
},
"opencl-headers": {
"dependency_names": [
"opencl-headers"
Expand Down
9 changes: 9 additions & 0 deletions subprojects/openblas.wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[wrap-file]
directory = OpenBLAS-0.3.28
source_url = https://github.com/OpenMathLib/OpenBLAS/releases/download/v0.3.28/OpenBLAS-0.3.28.tar.gz
source_filename = OpenBLAS-0.3.28.tar.gz
source_hash = f1003466ad074e9b0c8d421a204121100b0751c96fc6fcf3d1456bd12f8a00a1
patch_directory = openblas

[provide]
openblas = openblas_dep
90 changes: 90 additions & 0 deletions subprojects/packagefiles/openblas/ctest/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
testl1_src = ['c_?blat1.f', 'c_?blas1.c']
testl2_src = ['c_?blat2.f', 'c_?blas2.c', 'c_?2chke.c', 'auxiliary.c', 'constant.c', 'c_xerbla.c']
testl3_src = ['c_?blat3.f', 'c_?blas3.c', 'c_?3chke.c', 'auxiliary.c', 'constant.c', 'c_xerbla.c']
testl3_3m_src = ['c_?blat3_3m.f', 'c_?blas3_3m.c', 'c_?3chke_3m.c', 'auxiliary.c', 'constant.c', 'c_xerbla.c']

_test_input_array = {
'l1': {
'base': 'x?blat1',
'has_dat': false,
'types': ['s', 'd', 'c', 'z'],
'sources': testl1_src,
},
'l2': {
'base': 'x?cblat2',
'has_dat': true,
'types': ['s', 'd', 'c', 'z'],
'sources': testl2_src,
'input_file': '?in2',
},
'l3': {
'base': 'x?cblat3',
'has_dat': true,
'types': ['s', 'd', 'c', 'z'],
'sources': testl3_src,
'input_file': '?in3',
},
}

lvls = ['l1', 'l3']
# TODO(rg) : Times out..
if not is_win
lvls += ['l2']
endif

if conf_hdat.has('ARCH_X86_64') or conf_hdat.has('ARCH_X86')
_test_input_array += {
'l3_3m': {
'base': 'x?cblat3_3m',
'has_dat': true,
'types': ['c', 'z'],
'sources': testl3_3m_src,
'input_file': '?in3_3m',
}
}
lvls += 'l3_3m'
endif

_test_runner = executable('test_runner', sources: ['test_runner.c'], install: false)
ctest_inc = _inc + [include_directories('.')]

foreach lvl : lvls
details = _test_input_array[lvl]

foreach type : details['types']
op_name = details['base'].replace('?', type)

mapped_sources = []
foreach source : details['sources']
mapped_sources += source.replace('?', type)
endforeach

executable(
op_name,
sources: mapped_sources,
link_with: [openblas_static],
dependencies: [dependency('threads')],
include_directories: ctest_inc,
c_args: ['-DADD_', '-DCBLAS'],
)

if is_win
obj_name = op_name
else
obj_name = f'./@op_name@'
endif

_args = [obj_name]
if details.has_key('input_file')
_args += [meson.current_source_dir() / details['input_file'].replace('?', type)]
endif

test(
op_name,
_test_runner,
args: _args,
workdir: meson.current_build_dir(),
) # TODO: add OPENBLAS_NUM_THREADS=2

endforeach
endforeach
24 changes: 24 additions & 0 deletions subprojects/packagefiles/openblas/ctest/test_runner.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {
if (argc != 2 && argc != 3) {
fprintf(stderr, "Usage: %s <executable> <optional_input_file>\n", argv[0]);
return EXIT_FAILURE;
}

char command[1024];
if (argc == 2) {
snprintf(command, sizeof(command), "%s", argv[1]);
} else {
snprintf(command, sizeof(command), "%s < %s", argv[1], argv[2]);
}

int result = system(command);
if (result != EXIT_SUCCESS) {
fprintf(stderr, "Error: Command '%s' failed with return code %d.\n", command, result);
return EXIT_FAILURE;
}

return EXIT_SUCCESS;
}
Loading

0 comments on commit bdb5dbe

Please sign in to comment.