Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config: add BLIS, sync with BLAS++ #73

Merged
merged 1 commit into from
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
__pycache__
lapackpp-*
build*
config/acml_version
config/blas
config/blis_version
config/cblas
config/compiler_cxx
config/cublas
Expand Down
22 changes: 6 additions & 16 deletions cmake/LAPACKFinder.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -51,30 +51,19 @@ endif()
#---------------------------------------- lapack
string( TOLOWER "${lapack}" lapack_ )

if ("${lapack_}" MATCHES "auto")
set( test_all true )
endif()

if ("${lapack_}" MATCHES "default")
set( test_default true )
endif()

if ("${lapack_}" MATCHES "generic")
set( test_generic true )
endif()
string( REGEX MATCH "auto|default" test_default "${lapack_}" )
string( REGEX MATCH "auto|generic" test_generic "${lapack_}" )

message( DEBUG "
LAPACK_LIBRARIES = '${LAPACK_LIBRARIES}'
lapack = '${lapack}'
lapack_ = '${lapack_}'
test_lapack_libraries = '${test_lapack_libraries}'
test_default = '${test_default}'
test_generic = '${test_generic}'
test_all = '${test_all}'")
test_generic = '${test_generic}'" )

#-------------------------------------------------------------------------------
# Build list of libraries to check.
# todo: add flame?
# todo: LAPACK_?(ROOT|DIR)

set( lapack_libs_list "" )
Expand All @@ -89,12 +78,12 @@ if (test_lapack_libraries)
endif()

#---------------------------------------- default (in BLAS library)
if (test_all OR test_default)
if (test_default)
list( APPEND lapack_libs_list " " )
endif()

#---------------------------------------- generic -llapack
if (test_all OR test_generic)
if (test_generic)
list( APPEND lapack_libs_list "-llapack" )
endif()

Expand All @@ -106,6 +95,7 @@ message( DEBUG "lapack_libs_list ${lapack_libs_list}" )
# LAPACK++ checks for pstrf (Cholesky with pivoting) to make sure it is
# a complete LAPACK library, since some BLAS libraries (ESSL, ATLAS)
# contain only an optimized subset of LAPACK routines.
# ESSL lacks [cz]symv, [cz]syr.

unset( LAPACK_FOUND CACHE )
unset( lapackpp_defs_ CACHE )
Expand Down
10 changes: 10 additions & 0 deletions config/blas.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "config.h"

//------------------------------------------------------------------------------
#define BLAS_ddot FORTRAN_NAME( ddot, DDOT )

// result return directly
Expand All @@ -19,6 +20,7 @@ double BLAS_ddot(
const double* x, const blas_int* incx,
const double* y, const blas_int* incy );

//------------------------------------------------------------------------------
int main()
{
// If blas_int is 32-bit, but BLAS actually interprets it as 64-bit,
Expand All @@ -28,7 +30,15 @@ int main()
blas_int n[] = { 5, 5 }, ione = 1;
double x[] = { 1, 2, 3, 4, 5 };
double y[] = { 5, 4, 3, 2, 1 };
for (int i = 0; i < n[0]; ++i) {
printf( "x[ %d ] = %.1f; y[ %d ] = %.1f\n",
i, x[ i ],
i, y[ i ] );
}

double result = BLAS_ddot( n, x, &ione, y, &ione );
printf( "result = %.1f; should be 35.0\n", result );

bool okay = (result == 35);
printf( "%s\n", okay ? "ok" : "failed" );
return ! okay;
Expand Down
10 changes: 4 additions & 6 deletions config/acml_version.cc → config/blis_version.cc
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
// Copyright (c) 2017-2023, University of Tennessee. All rights reserved.
// Copyright (c) 2017-2024, University of Tennessee. All rights reserved.
// SPDX-License-Identifier: BSD-3-Clause
// This program is free software: you can redistribute it and/or modify it under
// the terms of the BSD 3-Clause license. See the accompanying LICENSE file.

#include <stdio.h>
#include <mkl.h>
#include <blis.h>

int main()
{
int major, minor, patch, build;
acmlversion( &major, &minor, &patch, &build );
printf( "ACML_VERSION=%d.%d.%d.%d\n",
major, minor, patch, build );
const char* v = bli_info_get_version_str();
printf( "BLIS_VERSION=%s\n", v );
return 0;
}
9 changes: 9 additions & 0 deletions config/cblas.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,21 @@
#endif
#endif

//------------------------------------------------------------------------------
int main()
{
int n = 5;
double x[] = { 1, 2, 3, 4, 5 };
double y[] = { 5, 4, 3, 2, 1 };
for (int i = 0; i < n; ++i) {
printf( "x[ %d ] = %.1f; y[ %d ] = %.1f\n",
i, x[ i ],
i, y[ i ] );
}

double result = cblas_ddot( n, x, 1, y, 1 );
printf( "result = %.1f; should be 35.0\n", result );

bool okay = (result == 35);
printf( "%s\n", okay ? "ok" : "failed" );
return ! okay;
Expand Down
2 changes: 1 addition & 1 deletion config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ def parse_args():

# Parse name=value pairs.
for arg in opts.options:
s = re.search( '^(\w+)=(.*)', arg )
s = re.search( r'^(\w+)=(.*)', arg )
if (s):
environ[ s.group(1) ] = s.group(2)
else:
Expand Down
Loading