MKLConfig#
-
class numpy::MKLConfig#
numpy C++ class.
Example#
#include <numpy/np_ndarray.h>
using namespace numpy;
// Use MKLConfig
MKLConfig obj;
// ... operations ...
Indexing / Selection#
Signature |
Return Type |
Location |
Example |
|---|---|---|---|
|
Backend |
MKL_CONFIG.H:183 |
Other Methods#
Code Examples#
The following examples are extracted from the test suite.
get_default_backend (np_test_1_all.cpp:25367)
25357 // std::cout << "[OK] BoostInfo tests passed" << std::endl;
25358 }
25359
25360 void test_boost_config() {
25361 std::cout << "========= Testing BoostConfig ===================";
25362
25363 using namespace numpy::boost_lib;
25364
25365 // Test default backend
25366 Backend default_backend = BoostConfig::get_default_backend();
25367 // std::cout << "Default backend: "
25368 // << (default_backend == Backend::AUTO ? "AUTO" :
25369 // default_backend == Backend::BOOST ? "BOOST" : "STANDARD")
25370 // << std::endl;
25371
25372 // Test backend resolution
25373 Backend resolved_auto = BoostConfig::resolve_backend(Backend::AUTO);
25374 // std::cout << "Resolved AUTO backend: "
25375 // << (resolved_auto == Backend::BOOST ? "BOOST" : "STANDARD")
25376 // << std::endl;
resolve_backend (np_test_1_all.cpp:25374)
25364 using namespace numpy::boost_lib;
25365
25366 // Test default backend
25367 Backend default_backend = BoostConfig::get_default_backend();
25368 // std::cout << "Default backend: "
25369 // << (default_backend == Backend::AUTO ? "AUTO" :
25370 // default_backend == Backend::BOOST ? "BOOST" : "STANDARD")
25371 // << std::endl;
25372
25373 // Test backend resolution
25374 Backend resolved_auto = BoostConfig::resolve_backend(Backend::AUTO);
25375 // std::cout << "Resolved AUTO backend: "
25376 // << (resolved_auto == Backend::BOOST ? "BOOST" : "STANDARD")
25377 // << std::endl;
25378
25379 // Test should_use_boost
25380 bool use_boost = BoostConfig::should_use_boost(Backend::AUTO);
25381 // std::cout << "Should use Boost (AUTO): " << (use_boost ? "Yes" : "No") << std::endl;
25382
25383 // Verify consistency
25384 if (BoostInfo::is_runtime_available()) {
set_default_backend (np_test_1_all.cpp:25414)
25404 // Test forced STANDARD backend
25405 bool use_standard = BoostConfig::should_use_boost(Backend::STANDARD);
25406 if (use_standard) {
25407 throw std::runtime_error("Forced STANDARD backend not working");
25408 }
25409 // std::cout << "[OK] Forced STANDARD backend works" << std::endl;
25410
25411 // Test backend setting
25412 Backend original = BoostConfig::get_default_backend();
25413 BoostConfig::set_default_backend(Backend::STANDARD);
25414 if (BoostConfig::get_default_backend() != Backend::STANDARD) {
25415 throw std::runtime_error("Backend setting not working");
25416 }
25417 BoostConfig::set_default_backend(original); // Restore
25418 // std::cout << "[OK] Backend setting works" << std::endl;
25419
25420 // std::cout << "[OK] BoostConfig tests passed" << std::endl;
25421 }
25422
25423#if BOOST_ENABLED
should_use_mkl (np_test_3_all.cpp:17749)
17739 return std::abs(a - b) <= (atol + rtol * std::abs(b));
17740 }
17741
17742 // ============================
17743 // LEVEL 1 BLAS TESTS
17744 // ============================
17745
17746 void np_test_mkl_dot() {
17747 std::cout << "========= mkl_dot test =======================";
17748#ifdef NUMPY_USE_MKL
17749 if (!mkl::MKLConfig::should_use_mkl()) {
17750 // std::cout << " [SKIP] MKL not available";
17751 return;
17752 }
17753
17754 // Test 1: Simple dot product with double
17755 {
17756 NDArray<double> x({ 3 });
17757 x.setElementAt({ 0 }, 1.0);
17758 x.setElementAt({ 1 }, 2.0);
17759 x.setElementAt({ 2 }, 3.0);