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

Segmentation Fault in poisson solver (mixing C & C++ Problem)

zudol0104
Novice
815 Views

Hello
I'm trying to embed MKL's Poisson solver in my own C++ code. I even succeeded in building & running the example included in the MKL Library, but the problem is that when I try to use it in my C++ code, I get a Segmentation Fault.
My code consists of 3 files.
        - d_Helmholtz_3D_c.h
        - d_Helmholtz_3D_c.c
        - main.cc

Where , "d_Helmholtz_3D_c.c " is a slight modification of the example file.
        int main() -> void poisson()

"d_Helmholtz_3D_c.h" is as follows

#ifndef __D_HELMHOLTZ_3D_C_HH
#define __D_HELMHOLTZ_3D_C_HH
void poisson();
#endif

"main.cc" is as follows

#include <iostream>
extern "C" {
#include "d_Helmholtz_3D_c.h"
}
int main() {
using std::cout;
using std::endl;
cout << "Main" << endl;
poisson();
return 0;
}

 

CMakeLists.txt is as follows

cmake_minimum_required (VERSION 3.16.2)
enable_testing()

set(CMAKE_C_COMPILER icc)
set(CMAKE_CXX_COMPILER icpc)

project (oneMKL_Example)
set(MKL_ROOT /my/dir/intel-oneAPI/mkl/latest/)
list(APPEND CMAKE_MODULE_PATH "MKL_ROOT/lib/cmake")
find_package(MKL CONFIG REQUIRED)

add_executable(myapp main.cc)
target_link_libraries(myapp PUBLIC poisson)
add_library(poisson d_Helmholtz_3D_c.c)
# add_executable(myapp d_Helmholtz_3D_c.c)

target_compile_options(myapp PUBLIC $<TARGET_PROPERTY:MKL::MKL,INTERFACE_COMPILE_OPTIONS>)
target_include_directories(myapp PUBLIC $<TARGET_PROPERTY:MKL::MKL,INTERFACE_INCLUDE_DIRECTORIES>)
target_link_libraries(myapp PUBLIC $<LINK_ONLY:MKL::MKL>)

 

The mkl version checked with mkl_get_version() is as follows.

Major version: 2021
Minor version: 0
Update version: 2
Product status: Product
Build: 20210312
Platform: Intel(R) 64 architecture
Processor optimization: Intel(R) Advanced Vector Extensions 2 (Intel(R) AVX2) enabled processors

Why on earth would a segmentation fault occur?

0 Kudos
4 Replies
ShanmukhS_Intel
Moderator
785 Views

Hi,


Thanks for posting in Intel Communities.


Thanks for sharing the detailed steps. It is always recommended to use the latest version of oneMKL. Hence, could you please try the latest oneMKL (2023.2), and let us know if the issue persists? We are looking into your issue. We will get back to you soon with an update.


Best Regards,

Shanmukh.SS


0 Kudos
ShanmukhS_Intel
Moderator
746 Views

Hi June,

 

We could see a segmentation fault occurring at the "d_commit_Helmholtz_3D" step of the d_Helmholtz_3D_c.c file.

 

Could you please add the -DMKL_ILP64 in the compile flag and let us know if the issue persists?

 

Best Regards,

Shanmukh.SS

 

0 Kudos
zudol0104
Novice
734 Views

I added -DMKL_ILP64 in the compile flag and it works

0 Kudos
ShanmukhS_Intel
Moderator
699 Views

Hi June,


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.


Best Regards,

Shanmukh.SS


0 Kudos
Reply