Skip to content

Commit e57df11

Browse files
Enabling xtensor-blas with xeus-cpp-lite (#252)
We have been using xtensor-blas with xeus-cpp-lite through a patch on emscripten-forge emscripten-forge/recipes#2318 This PR upstreams the necessary patch. We use the f2c based openblas build (providing libopenblas.so) on emscripten-forge to run xtensor-blas. --------- Co-authored-by: Johan Mabille <johan.mabille@gmail.com>
1 parent e4d5028 commit e57df11

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

include/xtensor-blas/xblas_config.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030
#include "xtensor-blas/xblas_config_cling.hpp"
3131
#endif
3232

33+
#if defined(__CLANG_REPL__) && defined(__EMSCRIPTEN__)
34+
#include "xtensor-blas/xblas_config_cling.hpp"
35+
#endif
36+
3337
namespace xt
3438
{
3539
using blas_index_t = BLAS_IDX;

include/xtensor-blas/xblas_config_cling.hpp.in

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,28 @@
1010
#ifndef XBLAS_CONFIG_CLING_HPP
1111
#define XBLAS_CONFIG_CLING_HPP
1212

13-
#pragma cling add_library_path(@XTENSOR_BLAS_CLING_LIBRARY_DIR_64@)
14-
#pragma cling add_library_path(@XTENSOR_BLAS_CLING_LIBRARY_DIR_32@)
15-
#pragma cling add_library_path(@XTENSOR_BLAS_CLING_LIBRARY_DIR@)
16-
1713
#ifndef XTENSOR_USE_FLENS_BLAS
1814

1915
#define HAVE_CBLAS 1
2016

17+
#if defined(__CLING__)
18+
19+
#pragma cling add_library_path(@XTENSOR_BLAS_CLING_LIBRARY_DIR_64@)
20+
#pragma cling add_library_path(@XTENSOR_BLAS_CLING_LIBRARY_DIR_32@)
21+
#pragma cling add_library_path(@XTENSOR_BLAS_CLING_LIBRARY_DIR@)
2122
#pragma cling load("libblas")
2223
#pragma cling load("liblapack")
2324

24-
#endif
25+
#elif defined(__EMSCRIPTEN__) && defined(__CLANG_REPL__)
26+
27+
#include <clang/Interpreter/CppInterOp.h>
28+
static bool _openblas_loaded = []() {
29+
Cpp::LoadLibrary(@OPENBLAS_CPPINTEROP_LIBRARY_PATH@, false);
30+
return true;
31+
}();
2532

2633
#endif
34+
35+
#endif // XTENSOR_USE_FLENS_BLAS
36+
37+
#endif // XBLAS_CONFIG_CLING_HPP

0 commit comments

Comments
 (0)