#include <map>
#include <string>
#include <cstring>
+#include <mutex>
#include <vector>
#if GNA_LIB_VER == 2
#include "details/ie_exception.hpp"
#include "gna_plugin_log.hpp"
+std::mutex GNADeviceHelper::acrossPluginsSync{};
+
uint8_t* GNADeviceHelper::alloc(uint32_t size_requested, uint32_t *size_granted) {
void * memPtr = nullptr;
#if GNA_LIB_VER == 1
return reqId;
}
#else
+
void GNADeviceHelper::setUpActiveList(const uint32_t requestConfigId, uint32_t layerIndex, uint32_t* ptr_active_indices, uint32_t num_active_indices) {
const auto status = Gna2RequestConfigEnableActiveList(requestConfigId, layerIndex, num_active_indices, ptr_active_indices);
checkGna2Status(status);
#endif
void GNADeviceHelper::open(uint8_t n_threads) {
+ std::unique_lock<std::mutex> lockGnaCalls{ acrossPluginsSync };
#if GNA_LIB_VER == 1
nGNAHandle = GNADeviceOpenSetThreads(&nGNAStatus, n_threads);
checkStatus();
}
void GNADeviceHelper::close() {
+ std::unique_lock<std::mutex> lockGnaCalls{ acrossPluginsSync };
#if GNA_LIB_VER == 1
GNADeviceClose(nGNAHandle);
nGNAHandle = 0;
}
void GNADeviceHelper::setOMPThreads(uint8_t const n_threads) {
+ std::unique_lock<std::mutex> lockGnaCalls{ acrossPluginsSync };
#if GNA_LIB_VER == 1
gmmSetThreads(n_threads);
#else
#include <cstdint>
#include <memory>
+#include <mutex>
#include <string>
#include <map>
#include <vector>
* holds gna - style handle in RAII way
*/
class GNADeviceHelper {
+ static std::mutex acrossPluginsSync;
#if GNA_LIB_VER == 1
intel_gna_status_t nGNAStatus = GNA_NOERROR;
intel_gna_handle_t nGNAHandle = 0;
void setOMPThreads(uint8_t const n_threads);
void initGnaPerfCounters() {
+ std::unique_lock<std::mutex> lockGnaCalls{ acrossPluginsSync };
#if GNA_LIB_VER == 1
nGNAPerfResults = {{0, 0, 0, 0, 0, 0, 0}, {0, 0}, {0, 0, 0}, {0, 0}};
nGNAPerfResultsTotal = {{0, 0, 0, 0, 0, 0, 0}, {0, 0}, {0, 0, 0}, {0, 0}};
}
// tested function: GetAvailableDevices, UnregisterPlugin
-// TODO: some plugins initialization (e.g. GNA) failed during such stress-test scenario
+// TODO: some initialization (e.g. thread/dlopen) sporadically fails during such stress-test scenario
TEST_F(CoreThreadingTests, DISABLED_GetAvailableDevices) {
InferenceEngine::Core ie;
runParallel([&] () {
--- /dev/null
+// Copyright (C) 2020 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include <behavior/core_threading_tests.hpp>
+
+namespace {
+
+Params params[] = {
+ std::tuple<Device, Config>{ CommonTestUtils::DEVICE_GNA, {{ CONFIG_KEY(PERF_COUNT), CONFIG_VALUE(YES) }}},
+ std::tuple<Device, Config>{ CommonTestUtils::DEVICE_HETERO, {{ "TARGET_FALLBACK", CommonTestUtils::DEVICE_GNA }}},
+ std::tuple<Device, Config>{ CommonTestUtils::DEVICE_MULTI, {{ MULTI_CONFIG_KEY(DEVICE_PRIORITIES), CommonTestUtils::DEVICE_GNA }}},
+};
+
+} // namespace
+
+INSTANTIATE_TEST_CASE_P(GNA, CoreThreadingTests, testing::ValuesIn(params), CoreThreadingTests::getTestCaseName);
+
+INSTANTIATE_TEST_CASE_P(DISABLED_GNA, CoreThreadingTestsWithIterations,
+ testing::Combine(testing::ValuesIn(params),
+ testing::Values(2),
+ testing::Values(2)),
+ CoreThreadingTestsWithIterations::getTestCaseName);