Bugfix for AOCL-BLAS bench application

- Bug : When configuring our library with the native
        BLIS integer size being 32, the bench application
	would crash or read an invalid value when parsing
        the input file. This is because of a mismatch
        of format specifier, that we hardset in the
        Makefile.

- Fix : Defined a header that sets the format specifiers
        as macros with the right matching, based on how we
        configure and build the library. It is expected to
        include this header in every source file for
        benchmarking.

AMD-Internal: [CPUPL-5895]
Change-Id: I9718c36a1a9fe3eba4d5da419823c16097902d89
This commit is contained in:
Vignesh Balasubramanian
2025-01-28 11:42:57 +05:30
committed by Vignesh Balasubramanian
parent 9fd2aebd25
commit 445327f255
18 changed files with 103 additions and 42 deletions

View File

@@ -5,7 +5,7 @@
# libraries.
#
# Copyright (C) 2014, The University of Texas at Austin
# Copyright (C) 2017 - 2024, Advanced Micro Devices, Inc. All rights reserved.
# Copyright (C) 2017 - 2025, Advanced Micro Devices, Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
@@ -254,17 +254,17 @@ $(TEST_OBJ_PATH)/%.o: $(TEST_SRC_PATH)/%.c
$(CC) $(CFLAGS) -c $< -o $@
bench_%_openblas.o: bench_%.c
$(CC) $(CFLAGS) -DBLAS=\"openblas\" $(NRTS) -DINT_FS=\"%ld\" -DUINT_FS=\"%lu\" -c $< -o $@
$(CC) $(CFLAGS) -DBLAS=\"openblas\" $(NRTS) -c $< -o $@
bench_%_atlas.o: bench_%.c
$(CC) $(CFLAGS) -DBLAS=\"atlas\" $(NRTS) -DINT_FS=\"%ld\" -DUINT_FS=\"%lu\" -c $< -o $@
$(CC) $(CFLAGS) -DBLAS=\"atlas\" $(NRTS) -c $< -o $@
bench_%_mkl.o: bench_%.c
$(CC) $(CFLAGS) -DBLAS=\"mkl\" $(NRTS) -DINT_FS=\"%ld\" -DUINT_FS=\"%lu\" -c $< -o $@
$(CC) $(CFLAGS) -DBLAS=\"mkl\" $(NRTS) -c $< -o $@
bench_%_blis.o: bench_%.c
$(CC) $(CFLAGS) -DBLAS=\"aocl\" $(NRTS) -DINT_FS=\"%ld\" -DUINT_FS=\"%lu\" -c $< -o $@
$(CC) $(CFLAGS) -DBLAS=\"aocl\" $(NRTS) -c $< -o $@
# -- Executable file rules --

View File

@@ -4,7 +4,7 @@
An object-based framework for developing high-performance BLAS-like
libraries.
Copyright (C) 2021 - 2024, Advanced Micro Devices, Inc. All rights reserved.
Copyright (C) 2021 - 2025, Advanced Micro Devices, Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
@@ -38,6 +38,7 @@
#include <unistd.h>
#endif
#include "blis.h"
#include "blis_int_type.h"
// Benchmark application to process aocl logs generated by BLIS library.
#ifndef DT
@@ -106,7 +107,7 @@ int main( int argc, char** argv )
{
#ifdef PRINT
fprintf (stdout, "Input = %s %c %ld %ld %6.3f\n",
fprintf (stdout, "Input = %s %c " INT_FS INT_FS "%6.3f\n",
tmp, dt_ch, n, incx, gflops);
#endif
if (dt_ch == 'D' || dt_ch == 'd') dt = BLIS_DOUBLE;
@@ -229,12 +230,12 @@ int main( int argc, char** argv )
printf( "data_amaxv_%s", BLAS );
p_inc++;
printf("( %2lu, 1:4 ) = [ %4lu %7.2f ], Max Index = %ld;\n",
printf("( %2lu, 1:4 ) = [ %4lu %7.2f ], Max Index =" INT_FS ";\n",
(unsigned long)(p_inc),
(unsigned long)n,
gflops, max_index);
fprintf (fout, "%s %c %ld %ld %ld %6.3f\n", tmp, dt_ch, n, incx, max_index, gflops);
fprintf (fout, "%s %c " INT_FS INT_FS INT_FS "%6.3f\n", tmp, dt_ch, n, incx, max_index, gflops);
fflush(fout);

View File

@@ -4,7 +4,7 @@
An object-based framework for developing high-performance BLAS-like
libraries.
Copyright (C) 2022 - 2024, Advanced Micro Devices, Inc. All rights reserved.
Copyright (C) 2022 - 2025, Advanced Micro Devices, Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
@@ -38,6 +38,7 @@
#include <unistd.h>
#endif
#include "blis.h"
#include "blis_int_type.h"
#ifndef DT
#define DT BLIS_DOUBLE
@@ -253,7 +254,7 @@ int main( int argc, char** argv )
(unsigned long)n,
gflops );
fprintf( fout, "%s %c %ld %lf %lf %ld %lf %lf %ld %6.3f\n",
fprintf( fout, "%s %c " INT_FS " %lf %lf " INT_FS " %lf %lf " INT_FS "%6.3f\n",
tmp, dt_ch, n, alpha_r, alpha_i, incx, beta_r, beta_i, incy, gflops );
fflush( fout );

View File

@@ -4,7 +4,7 @@
An object-based framework for developing high-performance BLAS-like
libraries.
Copyright (C) 2024, Advanced Micro Devices, Inc. All rights reserved.
Copyright (C) 2024 - 2025, Advanced Micro Devices, Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
@@ -38,6 +38,7 @@
#include <unistd.h>
#endif
#include "blis.h"
#include "blis_int_type.h"
#ifndef DT
#define DT BLIS_DOUBLE
@@ -246,7 +247,7 @@ int main( int argc, char** argv )
(unsigned long)n,
gflops );
fprintf( fout, "%s %c %ld %lf %lf %ld %ld %6.3f\n",
fprintf( fout, "%s %c " INT_FS " %lf %lf " INT_FS INT_FS "%6.3f\n",
tmp, dt_ch, n, alpha_r, alpha_i, incx, incy, gflops );
fflush( fout );

View File

@@ -4,7 +4,7 @@
An object-based framework for developing high-performance BLAS-like
libraries.
Copyright (C) 2021 - 2024, Advanced Micro Devices, Inc. All rights reserved.
Copyright (C) 2021 - 2025, Advanced Micro Devices, Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
@@ -38,6 +38,7 @@
#include <unistd.h>
#endif
#include "blis.h"
#include "blis_int_type.h"
// Benchmark application to process aocl logs generated by BLIS library.
@@ -106,7 +107,7 @@ int main( int argc, char** argv )
{
#ifdef PRINT
fprintf (stdout, "Input = %s %c %ld %ld %ld\n",
fprintf (stdout, "Input = %s %c " INT_FS INT_FS INT_FS "\n",
tmp, dt_ch, n, incx, incy);
#endif
@@ -251,7 +252,7 @@ int main( int argc, char** argv )
(unsigned long)n,
gflops);
fprintf (fout, "%s %c %ld %ld %ld %6.3f\n",
fprintf (fout, "%s %c " INT_FS INT_FS INT_FS "%6.3f\n",
tmp, dt_ch, n, incx, incy, gflops);
fflush(fout);

View File

@@ -4,7 +4,7 @@
An object-based framework for developing high-performance BLAS-like
libraries.
Copyright (C) 2021 - 2024, Advanced Micro Devices, Inc. All rights reserved.
Copyright (C) 2021 - 2025, Advanced Micro Devices, Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
@@ -38,6 +38,7 @@
#include <unistd.h>
#endif
#include "blis.h"
#include "blis_int_type.h"
// Benchmark application to process aocl logs generated by BLIS library.
@@ -109,7 +110,7 @@ int main( int argc, char** argv )
{
#ifdef PRINT
fprintf (stdout, "Input = %s %c %c %ld %ld %ld %6.3f\n",
fprintf (stdout, "Input = %s %c %c " INT_FS INT_FS INT_FS "%6.3f\n",
tmp, dt_ch, conjx_ch, n, incx, incy, gflops);
#endif
@@ -335,7 +336,8 @@ int main( int argc, char** argv )
(unsigned long)n,
gflops);
fprintf (fout, "%s %c %c %ld %ld %ld %6.3f\n", tmp, dt_ch, conjx_ch, n, incx, incy, gflops);
fprintf (fout, "%s %c %c " INT_FS INT_FS INT_FS "%6.3f\n",
tmp, dt_ch, conjx_ch, n, incx, incy, gflops);
fflush(fout);

View File

@@ -5,7 +5,7 @@
libraries.
Copyright (C) 2014, The University of Texas at Austin
Copyright (C) 2020 - 2024, Advanced Micro Devices, Inc. All rights reserved.
Copyright (C) 2020 - 2025, Advanced Micro Devices, Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
@@ -39,6 +39,7 @@
#include <unistd.h>
#endif
#include "blis.h"
#include "blis_int_type.h"
// Benchmark application to process aocl logs generated by BLIS library.
@@ -482,7 +483,7 @@ int main( int argc, char** argv )
(unsigned long)n,
(unsigned long)k, gflops);
fprintf (fout, "%s %c %c %c %ld %ld %ld %lf %lf %ld %ld %lf %lf %ld %6.3f\n", \
fprintf (fout, "%s %c %c %c" INT_FS INT_FS INT_FS "%lf %lf" INT_FS INT_FS "%lf %lf" INT_FS "%6.3f\n", \
api_name, dt_ch, transA_c, transB_c, m, n, k, alpha_r, alpha_i, lda, ldb, beta_r, beta_i, ldc, gflops);
fflush(fout);

View File

@@ -38,6 +38,7 @@
#include <unistd.h>
#endif
#include "blis.h"
#include "blis_int_type.h"
// Benchmark application to process aocl logs generated by BLIS library.
@@ -974,7 +975,7 @@ int main( int argc, char** argv )
(unsigned long)n,
(unsigned long)k, gflops);
fprintf (fout, "%c %c %c %c %c %ld %ld %ld %lf %lf %ld %ld %lf %lf %ld %6.3f\n", \
fprintf (fout, "%c %c %c %c %c " INT_FS INT_FS INT_FS " %lf %lf " INT_FS INT_FS " %lf %lf " INT_FS "%6.3f\n", \
dt_ch, transA_c, transB_c, packA_c, packB_c, m, n, k, alpha_r, alpha_i, lda, ldb, beta_r, beta_i, ldc, gflops);
fflush(fout);

View File

@@ -4,7 +4,7 @@
An object-based framework for developing high-performance BLAS-like
libraries.
Copyright (C) 2020 - 2024, Advanced Micro Devices, Inc. All rights reserved.
Copyright (C) 2020 - 2025, Advanced Micro Devices, Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
@@ -38,6 +38,7 @@
#include <unistd.h>
#endif
#include "blis.h"
#include "blis_int_type.h"
// Benchmark application to process aocl logs generated by BLIS library.
#ifndef DT
@@ -464,7 +465,7 @@ int main( int argc, char** argv )
( unsigned long )n,
( unsigned long )k, gflops );
fprintf(fout, "%s %c %c %ld %ld %ld %ld %ld %c %c %lf %lf %lf %lf %6.3f\n", \
fprintf(fout, "%s %c %c" INT_FS INT_FS UINT_FS UINT_FS UINT_FS "%c %c %lf %lf %lf %lf %6.3f\n", \
tmp, dt_ch, uplo_c, n, k, lda, ldb, ldc,
transA_c,
transB_c,

View File

@@ -4,7 +4,7 @@
An object-based framework for developing high-performance BLAS-like
libraries.
Copyright (C) 2021 - 2024, Advanced Micro Devices, Inc. All rights reserved.
Copyright (C) 2021 - 2025, Advanced Micro Devices, Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
@@ -38,6 +38,7 @@
#include <unistd.h>
#endif
#include "blis.h"
#include "blis_int_type.h"
// Benchmark application to process aocl logs generated by BLIS library.
@@ -396,7 +397,7 @@ int main( int argc, char** argv )
(unsigned long)n,
gflops);
fprintf (fout, "%s %c %c %ld %ld %lf %lf %ld %ld %lf %lf %ld %6.3f\n",
fprintf (fout, "%s %c %c " INT_FS INT_FS " %lf %lf " INT_FS INT_FS " %lf %lf " INT_FS " %6.3f\n",
tmp, dt_ch, transA, m, n, alpha_r, alpha_i, lda,\
incx, beta_r, beta_i, incy, gflops);

View File

@@ -4,7 +4,7 @@
An object-based framework for developing high-performance BLAS-like
libraries.
Copyright (C) 2021 - 2024, Advanced Micro Devices, Inc. All rights reserved.
Copyright (C) 2021 - 2025, Advanced Micro Devices, Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
@@ -38,6 +38,7 @@
#include <unistd.h>
#endif
#include "blis.h"
#include "blis_int_type.h"
// Benchmark application to process aocl logs generated by BLIS library.
@@ -121,7 +122,7 @@ int main( int argc, char** argv )
{
#ifdef PRINT
fprintf (stdout, "Input = %s %c %ld %ld %lf %lf %ld %ld %ld %6.3f\n",
fprintf (stdout, "Input = %s %c " INT_FS INT_FS " %lf %lf " INT_FS INT_FS INT_FS "%6.3f\n",
tmp, dt_ch, m, n, alpha_r, alpha_i, incx, incy, lda, gflops);
#endif
@@ -321,7 +322,7 @@ int main( int argc, char** argv )
(unsigned long)n,
gflops);
fprintf (fout, "%s %c %ld %ld %lf %lf %ld %ld %ld %6.3f\n",
fprintf (fout, "%s %c " INT_FS INT_FS " %lf %lf " INT_FS INT_FS INT_FS " %6.3f\n",
tmp, dt_ch, m, n, alpha_r, alpha_i, incx, incy, lda, gflops);
fflush(fout);

View File

@@ -4,7 +4,7 @@
An object-based framework for developing high-performance BLAS-like
libraries.
Copyright (C) 2022 - 2024, Advanced Micro Devices, Inc. All rights reserved.
Copyright (C) 2022 - 2025, Advanced Micro Devices, Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
@@ -38,6 +38,7 @@
#include <unistd.h>
#endif
#include "blis.h"
#include "blis_int_type.h"
// Benchmark application to process aocl logs generated by BLIS library.
@@ -112,7 +113,7 @@ int main( int argc, char** argv )
{
#ifdef PRINT
fprintf (stdout, "Input = %s %c %ld %ld\n",
fprintf (stdout, "Input = %s %c" INT_FS INT_FS "\n",
tmp, dt_ch, n, incx);
#endif
@@ -225,7 +226,7 @@ int main( int argc, char** argv )
(unsigned long)n,
gflops);
fprintf (fout, "%s %c %ld %ld %6.3f\n",
fprintf (fout, "%s %c" INT_FS INT_FS "%6.3f\n",
tmp, dt_ch, n, incx, gflops);
fflush(fout);

View File

@@ -4,7 +4,7 @@
An object-based framework for developing high-performance BLAS-like
libraries.
Copyright (C) 2021 - 2024, Advanced Micro Devices, Inc. All rights reserved.
Copyright (C) 2021 - 2025, Advanced Micro Devices, Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
@@ -38,6 +38,7 @@
#include <unistd.h>
#endif
#include "blis.h"
#include "blis_int_type.h"
// Benchmark application to process aocl logs generated by BLIS library.
@@ -112,7 +113,7 @@ int main( int argc, char** argv )
dt_ch[2] = '\0'; // Null terminating the string for logging purpose
#ifdef PRINT
fprintf (stdout, "Input = %s %s %lf %lf %ld %ld\n",
fprintf (stdout, "Input = %s %s %lf %lf " INT_FS INT_FS "\n",
tmp, dt_ch, alpha_r, alpha_i, n, incx);
#endif
// Acquiring the datatype of input vector x
@@ -289,7 +290,7 @@ int main( int argc, char** argv )
(unsigned long)n,
gflops);
fprintf (fout, "%s %s %lf %lf %ld %ld %6.3f\n",
fprintf (fout, "%s %s %lf %lf " INT_FS INT_FS "%6.3f\n",
tmp, dt_ch, alpha_r, alpha_i, n, incx, gflops);
fflush(fout);

View File

@@ -4,7 +4,7 @@
An object-based framework for developing high-performance BLAS-like
libraries.
Copyright (C) 2021 - 2024, Advanced Micro Devices, Inc. All rights reserved.
Copyright (C) 2021 - 2025, Advanced Micro Devices, Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
@@ -38,6 +38,7 @@
#include <unistd.h>
#endif
#include "blis.h"
#include "blis_int_type.h"
// Benchmark application to process aocl logs generated by BLIS library.
@@ -235,7 +236,7 @@ int main( int argc, char** argv )
(unsigned long)n,
gflops);
fprintf (fout, "%s %c %ld %ld %ld %6.3f\n", tmp, dt_ch, n, incx, incy, gflops);
fprintf (fout, "%s %c " INT_FS INT_FS INT_FS "%6.3f\n", tmp, dt_ch, n, incx, incy, gflops);
fflush(fout);

View File

@@ -4,7 +4,7 @@
An object-based framework for developing high-performance BLAS-like
libraries.
Copyright (C) 2021 - 2024, Advanced Micro Devices, Inc. All rights reserved.
Copyright (C) 2021 - 2025, Advanced Micro Devices, Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
@@ -38,6 +38,7 @@
#include <unistd.h>
#endif
#include "blis.h"
#include "blis_int_type.h"
// Benchmark application to process aocl logs generated by BLIS library.
#ifndef DT
@@ -412,7 +413,7 @@ int main( int argc, char** argv )
( unsigned long )n,
( unsigned long )k, gflops );
fprintf(fout, "%s %c %c %c %ld %ld %lf %lf %lu %lf %lf %lu %6.3f\n", \
fprintf(fout, "%s %c %c %c " INT_FS INT_FS " %lf %lf " UINT_FS " %lf %lf " UINT_FS " %6.3f\n", \
tmp, dt_ch, uplo_c, transA_c, n, k,
alpha_r, alpha_i,
lda, beta_r, beta_i,

View File

@@ -5,7 +5,7 @@
libraries.
Copyright (C) 2014, The University of Texas at Austin
Copyright (C) 2020 - 2024, Advanced Micro Devices, Inc. All rights reserved.
Copyright (C) 2020 - 2025, Advanced Micro Devices, Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
@@ -37,6 +37,7 @@
#include <unistd.h>
#endif
#include "blis.h"
#include "blis_int_type.h"
/*
Benchmark application to process aocl logs generated
by BLIS library for trsm.

View File

@@ -4,7 +4,7 @@
An object-based framework for developing high-performance BLAS-like
libraries.
Copyright (C) 2021 - 2024, Advanced Micro Devices, Inc. All rights reserved.
Copyright (C) 2021 - 2025, Advanced Micro Devices, Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
@@ -38,6 +38,7 @@
#include <unistd.h>
#endif
#include "blis.h"
#include "blis_int_type.h"
@@ -383,7 +384,7 @@ int main( int argc, char** argv )
( unsigned long )p_inc,
( unsigned long )m, gflops );
fprintf (fout, "%s %c %c %c %c %ld %ld %ld %6.3f\n",
fprintf (fout, "%s %c %c %c %c " INT_FS INT_FS INT_FS "%6.3f\n",
tmp, dt_ch, uploa_c, transA, diaga_c, m, lda, incx, gflops);
fflush(fout);

44
bench/blis_int_type.h Normal file
View File

@@ -0,0 +1,44 @@
/*
BLIS
An object-based framework for developing high-performance BLAS-like
libraries.
Copyright (C) 2025, Advanced Micro Devices, Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name(s) of the copyright holder(s) nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// Defining the format specifier based on the BLIS configuration.
// NOTE : When blis-int-size is not explicitly specified, the underlying
// hardware is detected at compile time and the width is set.
#if BLIS_INT_TYPE_SIZE == 32
#define INT_FS " %d "
#define UINT_FS " %u "
#else
#define INT_FS " %ld "
#define UINT_FS " %lu "
#endif