Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
7185 Discussions

Warning in cblas macro when MKL_DIRECT_CALL defined

travbid
Beginner
1,682 Views

This is a minimal reproduction of my issue, which in real life occurs when including both dlib v19.22 and eigen 3.4.0 headers and defining EIGEN_USE_MKL_ALL

 

// main.cpp
#define MKL_DIRECT_CALL
#include "mkl.h"

inline void my_function(const CBLAS_ORDER Order, const CBLAS_SIDE Side,
                        const CBLAS_UPLO Uplo, const CBLAS_TRANSPOSE TransA,
                        const CBLAS_DIAG Diag, const int M, const int N,
                        const float alpha, const float *A, const int lda,
                        float *B, const int ldb) {
    cblas_strsm(Order, Side, Uplo, TransA, Diag, M, N, alpha, A, lda, B, ldb);
}

int main() {
    return 0;
}

 

Compiler: gcc 11.3.0

Command: /usr/bin/g++ -I/path/to/intel/oneapi/mkl/2023.1.0/include -std=c++17 -o ./main.cpp.o -c ./main.cpp

What I expect to see: No warnings

What I see instead: "warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]":

 

In file included from intel/oneapi/mkl/2023.1.0/include/mkl.h:47,
                 from main.cpp:2:
main.cpp: In function ‘void my_function(CBLAS_ORDER, CBLAS_SIDE, CBLAS_UPLO, CBLAS_TRANSPOSE, CBLAS_DIAG, int, int, float, const float*, int, float*, int)’:
intel/oneapi/mkl/2023.1.0/include/mkl_direct_call.h:470:25: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
  470 |     char *fside[]    = {"L", "R"};\
      |                         ^~~
intel/oneapi/mkl/2023.1.0/include/mkl_direct_call.h:524:83: note: in expansion of macro ‘MKL_DC_CBLAS_STRSM_CONVERT’
  524 | #define cblas_strsm(layout, side, uplo, trans, diag, m, n, alpha, a, lda, b, ldb) MKL_DC_CBLAS_STRSM_CONVERT(layout, side, uplo, trans, diag, m, n, alpha, a, lda, b, ldb, mkl_dc_strsm, strsm_direct)
      |                                                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:9:5: note: in expansion of macro ‘cblas_strsm’
   18 |                 cblas_strsm(Order, Side, Uplo, TransA, Diag, M, N, alpha, A, lda, B, ldb);
      |                 ^~~~~~~~~~~
intel/oneapi/mkl/2023.1.0/include/mkl_direct_call.h:470:30: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
  470 |     char *fside[]    = {"L", "R"};\
      |                              ^~~
intel/oneapi/mkl/2023.1.0/include/mkl_direct_call.h:524:83: note: in expansion of macro ‘MKL_DC_CBLAS_STRSM_CONVERT’
  524 | #define cblas_strsm(layout, side, uplo, trans, diag, m, n, alpha, a, lda, b, ldb) MKL_DC_CBLAS_STRSM_CONVERT(layout, side, uplo, trans, diag, m, n, alpha, a, lda, b, ldb, mkl_dc_strsm, strsm_direct)
      |                                                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:9:5: note: in expansion of macro ‘cblas_strsm’
   18 |                 cblas_strsm(Order, Side, Uplo, TransA, Diag, M, N, alpha, A, lda, B, ldb);
      |                 ^~~~~~~~~~~
intel/oneapi/mkl/2023.1.0/include/mkl_direct_call.h:471:25: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
  471 |     char *fuplo[]    = {"U", "L"};\
      |                         ^~~
intel/oneapi/mkl/2023.1.0/include/mkl_direct_call.h:524:83: note: in expansion of macro ‘MKL_DC_CBLAS_STRSM_CONVERT’
  524 | #define cblas_strsm(layout, side, uplo, trans, diag, m, n, alpha, a, lda, b, ldb) MKL_DC_CBLAS_STRSM_CONVERT(layout, side, uplo, trans, diag, m, n, alpha, a, lda, b, ldb, mkl_dc_strsm, strsm_direct)
      |                                                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:9:5: note: in expansion of macro ‘cblas_strsm’
   18 |                 cblas_strsm(Order, Side, Uplo, TransA, Diag, M, N, alpha, A, lda, B, ldb);
      |                 ^~~~~~~~~~~
intel/oneapi/mkl/2023.1.0/include/mkl_direct_call.h:471:30: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
  471 |     char *fuplo[]    = {"U", "L"};\
      |                              ^~~
intel/oneapi/mkl/2023.1.0/include/mkl_direct_call.h:524:83: note: in expansion of macro ‘MKL_DC_CBLAS_STRSM_CONVERT’
  524 | #define cblas_strsm(layout, side, uplo, trans, diag, m, n, alpha, a, lda, b, ldb) MKL_DC_CBLAS_STRSM_CONVERT(layout, side, uplo, trans, diag, m, n, alpha, a, lda, b, ldb, mkl_dc_strsm, strsm_direct)
      |                                                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:9:5: note: in expansion of macro ‘cblas_strsm’
   18 |                 cblas_strsm(Order, Side, Uplo, TransA, Diag, M, N, alpha, A, lda, B, ldb);
      |                 ^~~~~~~~~~~
intel/oneapi/mkl/2023.1.0/include/mkl_direct_call.h:472:25: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
  472 |     char *ftrans[]   = {"N", "T", "C"};\
      |                         ^~~
intel/oneapi/mkl/2023.1.0/include/mkl_direct_call.h:524:83: note: in expansion of macro ‘MKL_DC_CBLAS_STRSM_CONVERT’
  524 | #define cblas_strsm(layout, side, uplo, trans, diag, m, n, alpha, a, lda, b, ldb) MKL_DC_CBLAS_STRSM_CONVERT(layout, side, uplo, trans, diag, m, n, alpha, a, lda, b, ldb, mkl_dc_strsm, strsm_direct)
      |                                                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:9:5: note: in expansion of macro ‘cblas_strsm’
   18 |                 cblas_strsm(Order, Side, Uplo, TransA, Diag, M, N, alpha, A, lda, B, ldb);
      |                 ^~~~~~~~~~~
intel/oneapi/mkl/2023.1.0/include/mkl_direct_call.h:472:30: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
  472 |     char *ftrans[]   = {"N", "T", "C"};\
      |                              ^~~
intel/oneapi/mkl/2023.1.0/include/mkl_direct_call.h:524:83: note: in expansion of macro ‘MKL_DC_CBLAS_STRSM_CONVERT’
  524 | #define cblas_strsm(layout, side, uplo, trans, diag, m, n, alpha, a, lda, b, ldb) MKL_DC_CBLAS_STRSM_CONVERT(layout, side, uplo, trans, diag, m, n, alpha, a, lda, b, ldb, mkl_dc_strsm, strsm_direct)
      |                                                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:9:5: note: in expansion of macro ‘cblas_strsm’
   18 |                 cblas_strsm(Order, Side, Uplo, TransA, Diag, M, N, alpha, A, lda, B, ldb);
      |                 ^~~~~~~~~~~
intel/oneapi/mkl/2023.1.0/include/mkl_direct_call.h:472:35: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
  472 |     char *ftrans[]   = {"N", "T", "C"};\
      |                                   ^~~
intel/oneapi/mkl/2023.1.0/include/mkl_direct_call.h:524:83: note: in expansion of macro ‘MKL_DC_CBLAS_STRSM_CONVERT’
  524 | #define cblas_strsm(layout, side, uplo, trans, diag, m, n, alpha, a, lda, b, ldb) MKL_DC_CBLAS_STRSM_CONVERT(layout, side, uplo, trans, diag, m, n, alpha, a, lda, b, ldb, mkl_dc_strsm, strsm_direct)
      |                                                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:9:5: note: in expansion of macro ‘cblas_strsm’
   18 |                 cblas_strsm(Order, Side, Uplo, TransA, Diag, M, N, alpha, A, lda, B, ldb);
      |                 ^~~~~~~~~~~
intel/oneapi/mkl/2023.1.0/include/mkl_direct_call.h:473:25: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
  473 |     char *fdiag[]    = {"N", "U"};\
      |                         ^~~
intel/oneapi/mkl/2023.1.0/include/mkl_direct_call.h:524:83: note: in expansion of macro ‘MKL_DC_CBLAS_STRSM_CONVERT’
  524 | #define cblas_strsm(layout, side, uplo, trans, diag, m, n, alpha, a, lda, b, ldb) MKL_DC_CBLAS_STRSM_CONVERT(layout, side, uplo, trans, diag, m, n, alpha, a, lda, b, ldb, mkl_dc_strsm, strsm_direct)
      |                                                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:9:5: note: in expansion of macro ‘cblas_strsm’
   18 |                 cblas_strsm(Order, Side, Uplo, TransA, Diag, M, N, alpha, A, lda, B, ldb);
      |                 ^~~~~~~~~~~
intel/oneapi/mkl/2023.1.0/include/mkl_direct_call.h:473:30: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
  473 |     char *fdiag[]    = {"N", "U"};\
      |                              ^~~
intel/oneapi/mkl/2023.1.0/include/mkl_direct_call.h:524:83: note: in expansion of macro ‘MKL_DC_CBLAS_STRSM_CONVERT’
  524 | #define cblas_strsm(layout, side, uplo, trans, diag, m, n, alpha, a, lda, b, ldb) MKL_DC_CBLAS_STRSM_CONVERT(layout, side, uplo, trans, diag, m, n, alpha, a, lda, b, ldb, mkl_dc_strsm, strsm_direct)
      |                                                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:9:5: note: in expansion of macro ‘cblas_strsm’
   18 |                 cblas_strsm(Order, Side, Uplo, TransA, Diag, M, N, alpha, A, lda, B, ldb);
      |                 ^~~~~~~~~~~

 

 Would you be able to add `const` to these `char*` declarations to fix the warning? The `*_direct` functions that these variables are passed to already have `const char*` parameters.

I have attached a patch that fixes the issue for me for 2023.1

0 Kudos
3 Replies
VarshaS_Intel
Moderator
1,627 Views

Hi,


Thanks for posting in Intel Communities.


We are able to see the similar behavior at our end. We working on your issue, and we will get back to you soon.


Thanks & Regards,

Varsha


0 Kudos
VarshaS_Intel
Moderator
1,589 Views

Hi,

 

Thanks for your patience.

 

The issue raised by you is being looked at by the development team. We will update you once the issue is fixed.

 

Thanks & Regards,
Varsha

0 Kudos
VarshaS_Intel
Moderator
1,525 Views

Hi,


Thank you for your patience.


The issue raised by you has been targeted to be fixed in oneMKL 2024.0 version which will be released in the coming months. If the issue still persists with the new release, then you can start a new discussion for the community to investigate.


Please check the below link for all the updates regarding the Intel oneMKL, please find the link for release notes:

https://www.intel.com/content/www/us/en/developer/articles/release-notes/onemkl-release-notes.html


Have a Good Day!


Thanks & Regards,

Varsha


0 Kudos
Reply