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

MKL function parameters incompatible on Linux while compatible on Windows Visual Studio

runchan
Beginner
2,340 Views

I am wrting an algebra library for a large project using MKL.

The algebra library is working rightly on Linux now, i am now trying to make it work on Linux using CMake for cross-platform compiling.

Part of my CMakeLists.txt to link MKL is like this:

 

 

#find MKL on Linux
find_package(MKL REQUIRED)
message(STATUS "${MKL_IMPORTED_TARGETS}")
if(MKL_FOUND)
    message(STATUS "MKL IS FOUND ON LINUX")
    message(STATUS "MKL_ROOT IS ${MKL_ROOT}")
    include_directories(${MKL_ROOT}/include)
    target_link_libraries(algebra_test_linux PRIVATE MKL::mkl_intel_ilp64 MKL::mkl_intel_thread MKL::mkl_core MKL::MKL)
else()
    message(WARNING "MKL libs not found")
endif(MKL_FOUND)

 

 

 I think i have linked this programm to MKL because i run this code sample perfectly:

 

 

#include "mkl_test_linux.h"

#include<stdio.h>
#include<stdlib.h>
#include<mkl.h>
int main()
{
    float* A, * B;//declare two vectors
    int a = 1, b = 1;//
    int n = 5;
    A = (float*)mkl_malloc(n * 1 * sizeof(float), 64);
    B = (float*)mkl_malloc(n * 1 * sizeof(float), 64);
    printf("The 1st vector is ");
    for (int i = 0; i < n; i++) {
        A[i] = i;
        printf("%2.0f", A[i]);
    }
    printf("\n");
    printf("The 2st vector is ");
    for (int i = 0; i < n; i++) {
        B[i] = i + 1;
        printf("%2.0f", B[i]);
    }
    printf("\n");
    //计算a*A+b*B
    cblas_saxpby(n, a, A, 1, b, B, 1);
    printf("The a*A+b*B is ");
    for (int i = 0; i < n; i++) {
        printf("%2.0f", B[i]);
    }
    printf("\n");
    mkl_free(A);
    mkl_free(B);
    getchar();
    return 0;
}

 

 

However, my algebra_test on Linux come across many warnings like this :

runchan_0-1687937787664.png

runchan_0-1687999236239.png

 

I made some research telling me that this is caused by argument incompatible, but this is fine when i am using it on Windows.

I wonder how to fix this problem, thank you everyone.

0 Kudos
1 Solution
VarshaS_Intel
Moderator
2,151 Views

Hi,

 

Thanks for providing the details.

 

When we tried at our end using the CMakeProject in Visual Studio, we can get the expected results without any errors and we can build the project. We also tried on the Intel oneAPI command prompt and we do get warnings but we can build and run it successfully. You are facing an error it might be from a different project file.

 

Please find the attached screenshots where we are able to get the results on Visual Studio as well as on the Intel oneAPI command prompt.

 

Could you please let us if this the same you are following the same steps as creating the CMakeProject from Visual Studio 2022 and adding the C++ code along with CMakeFile? If not, could you please let us know the process/steps you followed to reproduce the issue on our end?

 

Thanks & Regards,

Varsha

 

View solution in original post

0 Kudos
5 Replies
VarshaS_Intel
Moderator
2,263 Views

Hi,


Thanks for posting in Intel Communities.


Could you please let us know the OS details, Intel MKL version, Intel C++ compiler, and Microsoft Visual Studio version(along with the subversion) you are using?


>>i am now trying to make it work on Linux using CMake for cross-platform compiling.

Could you please provide us with the complete CMakeLists.txt along with the complete steps you followed for cross-platform compiling to reproduce your issue at our end? 


And, could you please confirm whether you are facing errors only while compiling only cross-platform?


Thanks & Regards,

Varsha


0 Kudos
runchan
Beginner
2,253 Views

Thanks for your reply!

This is my Linux distribution version: Ubuntu 20.04.6 LTS (GNU/Linux 5.15.0-75-generic x86_64)

My Microsoft Visual Studio version is: Microsoft Visual Studio Community 2022(64 bit)-17.5.4

Here is full content of my CMakeLists.txt:

 

cmake_minimum_required (VERSION 3.13)
set(CMAKE_CXX_STANDARD 20)

# set(CMAKE_CXX_COMPILER i586-mingw32msvc-Eg++)
# set(CMAKE_CXX_COMPILER /data/opt/intel/oneapi/compiler/2023.1.0/linux/bin/icpx)

# search headers and libraries in the target environment
# set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
# set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

project(algebra_test_linux)

# search for source files needed
aux_source_directory(${PROJECT_SOURCE_DIR}/example example)
aux_source_directory(${PROJECT_SOURCE_DIR}/header header)
aux_source_directory(${PROJECT_SOURCE_DIR}/source source)

# add executable include headers needed
include_directories(${PROJECT_SOURCE_DIR}/header)
add_executable (algebra_test_linux ${header} ${source} ${PROJECT_SOURCE_DIR}/example/examples_algebra )

#find MKL on Linux
find_package(MKL REQUIRED)

message(STATUS "${MKL_IMPORTED_TARGETS}")
 if(MKL_FOUND)
    message(STATUS "MKL IS FOUND ON LINUX")
    message(STATUS "MKL_ROOT IS ${MKL_ROOT}")
    include_directories(${MKL_ROOT}/include)
    target_link_libraries(algebra_test_linux PRIVATE MKL::mkl_intel_ilp64 MKL::mkl_intel_thread MKL::mkl_core MKL::MKL)

else()
    message(WARNING "MKL libs not found")
endif(MKL_FOUND)

 

My MKL version is 2023.1.0

I did't specify a compiler on Linux, may be it's gcc be default?

On Windows i am using visual studio 2022 as the platform toolset, i donnot know what the exact compiler is.

I can confirm that i am facing these errors only while compiling only cross-platform.

 

0 Kudos
VarshaS_Intel
Moderator
2,152 Views

Hi,

 

Thanks for providing the details.

 

When we tried at our end using the CMakeProject in Visual Studio, we can get the expected results without any errors and we can build the project. We also tried on the Intel oneAPI command prompt and we do get warnings but we can build and run it successfully. You are facing an error it might be from a different project file.

 

Please find the attached screenshots where we are able to get the results on Visual Studio as well as on the Intel oneAPI command prompt.

 

Could you please let us if this the same you are following the same steps as creating the CMakeProject from Visual Studio 2022 and adding the C++ code along with CMakeFile? If not, could you please let us know the process/steps you followed to reproduce the issue on our end?

 

Thanks & Regards,

Varsha

 

0 Kudos
runchan
Beginner
2,118 Views

I have solved this question somehow. But anyway thank you for your suggestion! You are really kind and professional.

0 Kudos
VarshaS_Intel
Moderator
2,107 Views

Hi,


It’s great to know that the issue has been resolved, in case you run into any other issues please feel free to create a new thread.


Have a Good Day!


Thanks & Regards,

Varsha


0 Kudos
Reply