This patch implemnts dspm size for each device.
Each device has own dspm memory, and it needs to be device type for
presenting the size.
Signed-off-by: Jiho Chu <jiho.chu@samsung.com>
#include "ne-handler.h"
#include "ne-data.h"
+#include "typedef.h"
#include <npubinfmt.h>
#include <NPUdrvAPI.h>
switch (type & DEVICETYPE_MASK) {
case DEVICETYPE_TRIV2:
- device = new TrinityVision2 (id);
+ device = new TrinityVision2 ((type & DEVICEVERSION_MASK), id);
break;
case DEVICETYPE_DEPR:
logwarn (TAG, "You're trying to open deprecated devices..\n");
/** @brief Trinity Vision2 (TRIV2) class */
class TrinityVision2 : public Device {
public:
- TrinityVision2 (int id) : Device (NPUCOND_TRIV23_CONN_SOCIP, id) {}
+ TrinityVision2 (int dev_ver, int id)
+ : Device (dev_type (DEVICETYPE_TRIV2 | DEVICEGROUP_SOCIP | dev_ver), id) {}
~TrinityVision2 () {}
static size_t manipulateData (const Model *model, uint32_t idx, bool is_input, void *dst,
#include <iostream>
#define TAG _N94
-#define MAX_EMUL_DEVICES (4)
+#define MAX_EMUL_DEVICES (3)
#define TRIV23_DEFAULT_DSPM_SIZE (128 * 1024) /* 128 KiB */
-#define TRIV24_DEFAULT_DSPM_SIZE (256 * 1024) /* 128 KiB */
-#define RESERVED_DSPM_SIZE (64 * 1024) /* 64 KiB */
+#define TRIV24_DEFAULT_DSPM_SIZE (256 * 1024) /* 256 KiB */
+#define RESERVED_DSPM_SIZE (64 * 1024) /* 64 KiB */
#define ENVNAME_DSPM_SIZE ("MRPSIM_SPM_SIZE")
namespace {
return -EINVAL;
}
- *dspm = TRIV23_DEFAULT_DSPM_SIZE;
+ switch (dev_type_) {
+ case dev_type::NPUCOND_TRIV2_CONN_SOCIP:
+ *dspm = TRIV23_DEFAULT_DSPM_SIZE;
+ break;
+ case dev_type::NPUCOND_TRIV24_CONN_SOCIP:
+ *dspm = TRIV24_DEFAULT_DSPM_SIZE;
+ break;
+ default:
+ logerr (TAG, "Invalid device type");
+ return -EINVAL;
+ }
char *dspm_str = getenv (ENVNAME_DSPM_SIZE);
if (dspm_str != NULL) {
/**
* @brief Returns the number of available NPU devices.
+ * @param[in] type the NPU device type
* @return @c The number of NPU devices.
* @retval 0 if no NPU devices available. if positive (number of NPUs) if NPU devices available. otherwise, a negative error value.
* @note the caller should call putNPUdevice() to release the device handle
/**
* @brief Returns the handle of the chosen NPU devices.
* @param[out] dev The NPU device handle
+ * @param[in] type the NPU device type
* @param[in] id The NPU id to get the handle. 0 <= id < getnumNPUdeviceByType().
* @return @c 0 if no error. otherwise a negative error value
* @note the caller should call putNPUdevice() to release the device handle
EXPECT_GT (num_devices, 0);
/** directly creating a device instance but not initialized */
- std::unique_ptr<Device> triv2 (new TrinityVision2 (0));
+ std::unique_ptr<Device> triv2 (new TrinityVision2 (3, 0));
EXPECT_EQ (triv2->initialized (), false);
void *addr = nullptr;
#include <future>
#include <mutex>
#include <thread>
+#include "typedef.h"
#include <ne_test_utils_gtest.h>
EXPECT_LE (num_devices, 0);
}
+/**
+ * @brief check device dspm size
+ */
+TEST (ne_core_npu_test, check_dev_dspm_size) {
+ int num_devices = DriverAPI::getNumDevices (NPUCOND_TRIV2_CONN_UNKNOWN);
+ ASSERT_GT (num_devices, 0);
+ num_devices = DriverAPI::getNumDevices (NPUCOND_TRIV24_CONN_UNKNOWN);
+ ASSERT_GT (num_devices, 0);
+
+ auto api_23 = DriverAPI::createDriverAPI (NPUCOND_TRIV2_CONN_SOCIP, 0);
+ uint32_t dspm_size;
+ EXPECT_EQ (api_23->getDspmSize (&dspm_size), 0);
+ EXPECT_EQ (dspm_size, 64 * 1024);
+
+ auto api_24 = DriverAPI::createDriverAPI (NPUCOND_TRIV24_CONN_SOCIP, 0);
+ EXPECT_EQ (api_24->getDspmSize (&dspm_size), 0);
+ EXPECT_EQ (dspm_size, 192 * 1024);
+}
+
/**
* @brief check device statuses
*/