Skip to content

Commit

Permalink
Merge pull request #5029 from martin-frbg/issue5020
Browse files Browse the repository at this point in the history
Add support for compiling with Intel oneAPI 2025.0 on MS Windows
  • Loading branch information
martin-frbg authored Dec 24, 2024
2 parents 37a4ca7 + fbf594b commit 6af4e76
Show file tree
Hide file tree
Showing 17 changed files with 44 additions and 23 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

cmake_minimum_required(VERSION 3.16.0)

set (CMAKE_ASM_SOURCE_FILE_EXTENSIONS "S")
project(OpenBLAS C ASM)

set(OpenBLAS_MAJOR_VERSION 0)
Expand Down
6 changes: 4 additions & 2 deletions cmake/f_check.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@ if (NOT ONLY_CBLAS)

# TODO: detect whether underscore needed, set #defines and BU appropriately - use try_compile
# TODO: set FEXTRALIB flags a la f_check?

if (NOT (${CMAKE_SYSTEM_NAME} MATCHES "Windows" AND x${CMAKE_Fortran_COMPILER_ID} MATCHES "IntelLLVM"))
set(BU "_")
file(APPEND ${TARGET_CONF_TEMP}
"#define BUNDERSCORE _\n"
"#define NEEDBUNDERSCORE 1\n"
"#define NEED2UNDERSCORES 0\n")

else ()
set (FCOMMON_OPT "${FCOMMON_OPT} /fp:precise /recursive /names:lowercase /assume:nounderscore")
endif()
else ()

#When we only build CBLAS, we set NOFORTRAN=2
Expand Down
6 changes: 4 additions & 2 deletions cmake/prebuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ set(TARGET_CONF_TEMP "${PROJECT_BINARY_DIR}/${TARGET_CONF}.tmp")

# c_check
set(FU "")
if (APPLE OR (MSVC AND NOT ${CMAKE_C_COMPILER_ID} MATCHES "Clang"))
if (APPLE OR (MSVC AND NOT (${CMAKE_C_COMPILER_ID} MATCHES "Clang" OR ${CMAKE_C_COMPILER_ID} MATCHES "IntelLLVM")))
set(FU "_")
endif()
if(MINGW AND NOT MINGW64)
Expand Down Expand Up @@ -1433,7 +1433,9 @@ else(NOT CMAKE_CROSSCOMPILING)
message(STATUS "MSVC")
set(GETARCH_FLAGS ${GETARCH_FLAGS} -DFORCE_GENERIC)
else()
list(APPEND GETARCH_SRC ${PROJECT_SOURCE_DIR}/cpuid.S)
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
list(APPEND GETARCH_SRC ${PROJECT_SOURCE_DIR}/cpuid.S)
endif()
if (DEFINED TARGET_CORE)
set(GETARCH_FLAGS ${GETARCH_FLAGS} -DFORCE_${TARGET_CORE})
endif ()
Expand Down
3 changes: 3 additions & 0 deletions cmake/system.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,9 @@ endif ()
if (${CMAKE_C_COMPILER} STREQUAL "LSB" OR ${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
set(LAPACK_CFLAGS "${LAPACK_CFLAGS} -DLAPACK_COMPLEX_STRUCTURE")
endif ()
if (${CMAKE_C_COMPILER_ID} MATCHES "IntelLLVM" AND ${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
set(LAPACK_CFLAGS "${LAPACK_CFLAGS} -DNOCHANGE")
endif ()

if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
if ("${F_COMPILER}" STREQUAL "FLANG")
Expand Down
4 changes: 4 additions & 0 deletions ctest/cblas_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#define int long
#endif

#if defined(_MSC_VER) && defined(__INTEL_CLANG_COMPILER)
//#define LAPACK_COMPLEX_STRUCTURE
#define NOCHANGE
#endif
/* e.g. mingw64/x86_64-w64-mingw32/include/winerror.h */
#ifdef FAILED
#undef FAILED
Expand Down
8 changes: 7 additions & 1 deletion lapack-netlib/LAPACKE/include/lapacke_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,14 @@ extern "C" {
#define lapack_logical lapack_int
#endif

#if defined(_MSC_VER) && defined(__INTEL_CLANG_COMPILER)
#define LAPACK_COMPLEX_STRUCTURE
#define LAPACK_GLOBAL(lcname,UCNAME) lcname
#define NOCHANGE
#endif

#ifndef LAPACK_COMPLEX_CUSTOM
#if defined(_MSC_VER)
#if defined(_MSC_VER) && !defined(__INTEL_CLANG_COMPILER)
#define _CRT_USE_C_COMPLEX_H
#include <complex.h>
#define LAPACK_COMPLEX_CUSTOM
Expand Down
5 changes: 4 additions & 1 deletion utest/openblas_utest.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include <stdlib.h>
#include "ctest.h"

#if defined(_MSC_VER) && defined(__INTEL_CLANG_COMPILER)
//#define LAPACK_COMPLEX_STRUCTURE
#define NOCHANGE
#endif
#include <common.h>
#include <math.h>

Expand Down
8 changes: 4 additions & 4 deletions utest/test_extensions/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ void ztranspose(blasint rows, blasint cols, double *alpha, double *a_src, int ld
* param lda_dst - leading dimension of output matrix A
* param conj specifies conjugation
*/
void scopy(blasint rows, blasint cols, float alpha, float *a_src, int lda_src,
void my_scopy(blasint rows, blasint cols, float alpha, float *a_src, int lda_src,
float *a_dst, blasint lda_dst)
{
blasint i, j;
Expand All @@ -217,7 +217,7 @@ void scopy(blasint rows, blasint cols, float alpha, float *a_src, int lda_src,
}
}

void dcopy(blasint rows, blasint cols, double alpha, double *a_src, int lda_src,
void my_dcopy(blasint rows, blasint cols, double alpha, double *a_src, int lda_src,
double *a_dst, blasint lda_dst)
{
blasint i, j;
Expand All @@ -228,7 +228,7 @@ void dcopy(blasint rows, blasint cols, double alpha, double *a_src, int lda_src,
}
}

void ccopy(blasint rows, blasint cols, float *alpha, float *a_src, int lda_src,
void my_ccopy(blasint rows, blasint cols, float *alpha, float *a_src, int lda_src,
float *a_dst, blasint lda_dst, int conj)
{
blasint i, j;
Expand All @@ -243,7 +243,7 @@ void ccopy(blasint rows, blasint cols, float *alpha, float *a_src, int lda_src,
}
}

void zcopy(blasint rows, blasint cols, double *alpha, double *a_src, int lda_src,
void my_zcopy(blasint rows, blasint cols, double *alpha, double *a_src, int lda_src,
double *a_dst, blasint lda_dst, int conj)
{
blasint i, j;
Expand Down
10 changes: 5 additions & 5 deletions utest/test_extensions/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ extern void ctranspose(blasint rows, blasint cols, float *alpha, float *a_src, i
extern void ztranspose(blasint rows, blasint cols, double *alpha, double *a_src, int lda_src,
double *a_dst, blasint lda_dst, int conj);

extern void scopy(blasint rows, blasint cols, float alpha, float *a_src, int lda_src,
extern void my_scopy(blasint rows, blasint cols, float alpha, float *a_src, int lda_src,
float *a_dst, blasint lda_dst);
extern void dcopy(blasint rows, blasint cols, double alpha, double *a_src, int lda_src,
extern void my_dcopy(blasint rows, blasint cols, double alpha, double *a_src, int lda_src,
double *a_dst, blasint lda_dst);
extern void ccopy(blasint rows, blasint cols, float *alpha, float *a_src, int lda_src,
extern void my_ccopy(blasint rows, blasint cols, float *alpha, float *a_src, int lda_src,
float *a_dst, blasint lda_dst, int conj);
extern void zcopy(blasint rows, blasint cols, double *alpha, double *a_src, int lda_src,
extern void my_zcopy(blasint rows, blasint cols, double *alpha, double *a_src, int lda_src,
double *a_dst, blasint lda_dst, int conj);
#endif
#endif
2 changes: 1 addition & 1 deletion utest/test_extensions/test_cimatcopy.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ static float check_cimatcopy(char api, char order, char trans, blasint rows, bla
ctranspose(m, n, alpha, data_cimatcopy.a_test, lda_src, data_cimatcopy.a_verify, lda_dst, conj);
}
else {
ccopy(m, n, alpha, data_cimatcopy.a_test, lda_src, data_cimatcopy.a_verify, lda_dst, conj);
my_ccopy(m, n, alpha, data_cimatcopy.a_test, lda_src, data_cimatcopy.a_verify, lda_dst, conj);
}

if (api == 'F') {
Expand Down
2 changes: 1 addition & 1 deletion utest/test_extensions/test_comatcopy.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static float check_comatcopy(char api, char order, char trans, blasint rows, bla
ctranspose(m, n, alpha, data_comatcopy.a_test, lda, data_comatcopy.b_verify, ldb, conj);
}
else {
ccopy(m, n, alpha, data_comatcopy.a_test, lda, data_comatcopy.b_verify, ldb, conj);
my_ccopy(m, n, alpha, data_comatcopy.a_test, lda, data_comatcopy.b_verify, ldb, conj);
}

if (api == 'F') {
Expand Down
2 changes: 1 addition & 1 deletion utest/test_extensions/test_dimatcopy.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ static double check_dimatcopy(char api, char order, char trans, blasint rows, bl
dtranspose(m, n, alpha, data_dimatcopy.a_test, lda_src, data_dimatcopy.a_verify, lda_dst);
}
else {
dcopy(m, n, alpha, data_dimatcopy.a_test, lda_src, data_dimatcopy.a_verify, lda_dst);
my_dcopy(m, n, alpha, data_dimatcopy.a_test, lda_src, data_dimatcopy.a_verify, lda_dst);
}

if (api == 'F') {
Expand Down
2 changes: 1 addition & 1 deletion utest/test_extensions/test_domatcopy.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ static double check_domatcopy(char api, char order, char trans, blasint rows, bl
dtranspose(m, n, alpha, data_domatcopy.a_test, lda, data_domatcopy.b_verify, ldb);
}
else {
dcopy(m, n, alpha, data_domatcopy.a_test, lda, data_domatcopy.b_verify, ldb);
my_dcopy(m, n, alpha, data_domatcopy.a_test, lda, data_domatcopy.b_verify, ldb);
}

if (api == 'F') {
Expand Down
2 changes: 1 addition & 1 deletion utest/test_extensions/test_simatcopy.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ static float check_simatcopy(char api, char order, char trans, blasint rows, bla
stranspose(m, n, alpha, data_simatcopy.a_test, lda_src, data_simatcopy.a_verify, lda_dst);
}
else {
scopy(m, n, alpha, data_simatcopy.a_test, lda_src, data_simatcopy.a_verify, lda_dst);
my_scopy(m, n, alpha, data_simatcopy.a_test, lda_src, data_simatcopy.a_verify, lda_dst);
}

if (api == 'F') {
Expand Down
2 changes: 1 addition & 1 deletion utest/test_extensions/test_somatcopy.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ static float check_somatcopy(char api, char order, char trans, blasint rows, bla
stranspose(m, n, alpha, data_somatcopy.a_test, lda, data_somatcopy.b_verify, ldb);
}
else {
scopy(m, n, alpha, data_somatcopy.a_test, lda, data_somatcopy.b_verify, ldb);
my_scopy(m, n, alpha, data_somatcopy.a_test, lda, data_somatcopy.b_verify, ldb);
}

if (api == 'F') {
Expand Down
2 changes: 1 addition & 1 deletion utest/test_extensions/test_zimatcopy.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ static double check_zimatcopy(char api, char order, char trans, blasint rows, bl
ztranspose(m, n, alpha, data_zimatcopy.a_test, lda_src, data_zimatcopy.a_verify, lda_dst, conj);
}
else {
zcopy(m, n, alpha, data_zimatcopy.a_test, lda_src, data_zimatcopy.a_verify, lda_dst, conj);
my_zcopy(m, n, alpha, data_zimatcopy.a_test, lda_src, data_zimatcopy.a_verify, lda_dst, conj);
}

if (api == 'F') {
Expand Down
2 changes: 1 addition & 1 deletion utest/test_extensions/test_zomatcopy.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static double check_zomatcopy(char api, char order, char trans, blasint rows, bl
ztranspose(m, n, alpha, data_zomatcopy.a_test, lda, data_zomatcopy.b_verify, ldb, conj);
}
else {
zcopy(m, n, alpha, data_zomatcopy.a_test, lda, data_zomatcopy.b_verify, ldb, conj);
my_zcopy(m, n, alpha, data_zomatcopy.a_test, lda, data_zomatcopy.b_verify, ldb, conj);
}

if (api == 'F') {
Expand Down

0 comments on commit 6af4e76

Please sign in to comment.