device/gpu/api_internal/nn_device_api.cpp
/*
Loads & initializes device.

If succeeds fills device description structure and returns non-negative value.
If fails returns negative error-code.[TODO]
*/
Loads & initializes device.
If succeeds fills device description structure and returns non-negative value.
If fails returns negative error-code.[TODO]
Loads & initializes device . If succeeds fills device description structure and returns non - negative value . If fails returns negative error - code . [ TODO ]
int32_t nn_device_load(
    nn_device_description_t *const description  
) {
#define TO_STR_INNER(str) #str
#define TO_STR(str) TO_STR_INNER(str)
#ifdef DEBUG
#define COMPILER_CONF "DEBUG configuration";
#else
#define COMPILER_CONF "RELEASE configuration";
#endif
#if defined _WIN32
#   if defined (__ICC) || defined (__INTEL_COMPILER)
#      define COMPILER_DSCR   "ICC: " __VERSION__ "(Windows)"
#   elif defined _MSC_VER
#      define COMPILER_DSCR   "MSC: (Windows)" _MSC_FULL_VER
#   else
#      define COMPILER_DSCR   "Unknown compiler (Windows)"
#   endif
#else
#   if defined (__ICC) || defined (__INTEL_COMPILER)
#      define COMPILER_DSCR   "ICC: " __VERSION__ "(Unix)"
#   elif defined __GNUC__
#      define COMPILER_DSCR   "GNUC: " __VERSION__ "(Unix)"
#   else
#      define COMPILER_DSCR   "Unknown compiler (Unix)"
#   endif
#endif
        const char *device_description = "Floating point and OpenCL based GPU device for HSW GPU platforms|compiled " __DATE__ __TIME__"|using " TO_STR(COMPILER_DSCR) "|with " COMPILER_CONF;
    if( description == nullptr )
    {
        return -2;
    }
    else
    {
        *description = nn_device_description_t{
            NN_DEVICE_TYPE_GPU, 
            0,                  
            0,                  
            "GPU device",       
            device_description  
        };
    }
    try {
       device_interface_0.device =  reinterpret_cast<nn_device_t*>(new device_gpu::ocl_toolkit());
    }
    catch( device_gpu::runtime_error err )
    {
        std::cerr << err.what() << std::endl;
        return -1;
    }
    catch(...) {
       assert(0);   
       return -1;   
    }
    return 0;
}
int32_t nn_device_load ( nn_device_description_t * const description ) { #define TO_STR_INNER ( str )  #str #define TO_STR ( str )  TO_STR_INNER(str) #ifdef DEBUG #define COMPILER_CONF  "DEBUG configuration"; #else #define COMPILER_CONF  "RELEASE configuration"; #endif #if defined _WIN32 #   if defined ( __ICC ) || defined ( __INTEL_COMPILER ) #      define COMPILER_DSCR    "ICC: " __VERSION__ "(Windows)" #   elif defined _MSC_VER #      define COMPILER_DSCR    "MSC: (Windows)" _MSC_FULL_VER #   else #      define COMPILER_DSCR    "Unknown compiler (Windows)" #   endif #else #   if defined ( __ICC ) || defined ( __INTEL_COMPILER ) #      define COMPILER_DSCR    "ICC: " __VERSION__ "(Unix)" #   elif defined __GNUC__ #      define COMPILER_DSCR    "GNUC: " __VERSION__ "(Unix)" #   else #      define COMPILER_DSCR    "Unknown compiler (Unix)" #   endif #endif const char * device_description = " " __DATE__ __TIME__ " " TO_STR ( COMPILER_DSCR ) " " COMPILER_CONF ; if ( description == nullptr ) { return -2 ; } else { * description = nn_device_description_t { NN_DEVICE_TYPE_GPU , 0 , 0 , " " , device_description } ; } try { device_interface_0 . device = reinterpret_cast < nn_device_t * > ( new device_gpu :: ocl_toolkit ( ) ) ; } catch ( device_gpu :: runtime_error err ) { std :: cerr << err . what ( ) << std :: endl ; return -1 ; } catch ( ... ) { assert ( 0 ) ; return -1 ; } return 0 ; }
Loads & initializes device.
Loads & initializes device .
/* pointer to description structure */ // type // version_first // version_last // name // description // This should not happen. If we ever throw wrong type of object // It should be caught here