ncDeviceCreate()

Info Value
Header mvnc.h
Library libmvnc.so
Version 2.0
See also struct ncDeviceHandle_t, ncDeviceOption_t, ncDeviceOpen(), ncDeviceClose(), ncDeviceDestroy()

Overview

This function initializes a ncDeviceHandle_t struct.

You must create a separate handle for each neural compute device. Typical multi-device usage is to call this function repeatedly, starting with index = 0 and incrementing the index each time until an error is returned.

ncDeviceDestroy() frees the memory that is allocated with this function.

Prototype

ncStatus_t ncDeviceCreate(int index, struct ncDeviceHandle_t** deviceHandle);

Parameters

Name Type Description
index int The zero-based index of a neural compute device.
deviceHandle struct ncDeviceHandle_t** The address of a pointer to a ncDeviceHandle_t struct that will be created and initialized by this function.

Return

An appropriate value from the ncStatus_t enumeration.

Notes

Example

#include <stdio.h>
#include <stdlib.h>
#include <mvnc.h>

int main(int argc, char** argv)
{
    ncStatus_t retCode;
    struct ncDeviceHandle_t* deviceHandlePtr;
    
    // Initialize the device handle
    retCode = ncDeviceCreate(0, &deviceHandlePtr);
    if (retCode != NC_OK)
    {
        // Failed to initialize the device... maybe it isn't plugged in to the host
        printf("ncDeviceCreate Failed [%d]: Could not initialize the device.\n", retCode);
    }
    else
    {
        ncDeviceOpen(deviceHandlePtr);
        
        // Device handle is ready to use now, pass it to other API calls as needed...
            
        ncDeviceClose(deviceHandlePtr);
        ncDeviceDestroy(&deviceHandlePtr);
    }   
}