| 156 | } |
| 157 | |
| 158 | mluOpStatus_t MLUOP_WIN_API mluOpCreate(mluOpHandle_t *handle) { |
| 159 | PARAM_CHECK("[mluOpCreate]", handle != NULL); |
| 160 | |
| 161 | if (MLUOP_STATUS_SUCCESS != mluOpCheckDependency(true, false, ERROR)) { |
| 162 | LOG(ERROR) |
| 163 | << "Check version dependency failed in mluOpCreate function. " |
| 164 | << "If don't want this check, set env MLUOP_CHECK_DEP_VERSION to 0, " |
| 165 | << "but probably cause unexpected errors."; |
| 166 | return MLUOP_STATUS_NOT_INITIALIZED; |
| 167 | } |
| 168 | |
| 169 | CNdev mlu_dev; |
| 170 | int32_t cluster_num = 0; |
| 171 | int32_t core_num_per_cluster = 0; |
| 172 | int32_t nram_size = 0; |
| 173 | int32_t wram_size = 0; |
| 174 | int32_t sram_size = 0; |
| 175 | int32_t clock_rate = 0; |
| 176 | int32_t memory_clock_rate = 0; |
| 177 | int32_t memory_bus_width = 0; |
| 178 | int32_t l2cache_size = 0; |
| 179 | int32_t persisting_l2cache_maxsize = 0; |
| 180 | double memory_band_width = 0; |
| 181 | char device_name[CONTEXT_DEVICENAME_BUFFER_SIZE] = ""; |
| 182 | int device_code = 0; |
| 183 | mluOpContext *ctx = new (std::nothrow) mluOpContext(); |
| 184 | CNcontext drv_ctx; |
| 185 | CNctxConfigParam ctx_conf_param; |
| 186 | int dev = 0; |
| 187 | INTERNAL_CHECK("[mluOpCreate]", cnrtSuccess == cnrtGetDevice(&dev)); |
| 188 | INTERNAL_CHECK("[mluOpCreate]", cnrtSuccess == cnrtSetDevice(dev)); |
| 189 | INTERNAL_CHECK("[mluOpCreate]", CN_SUCCESS == cnCtxGetCurrent(&drv_ctx)); |
| 190 | INTERNAL_CHECK("[mluOpCreate]", CN_SUCCESS == cnCtxGetDevice(&mlu_dev)); |
| 191 | INTERNAL_CHECK("[mluOpCreate]", |
| 192 | CN_SUCCESS == cnSharedContextAcquire(&drv_ctx, mlu_dev)); |
| 193 | INTERNAL_CHECK( |
| 194 | "[mluOpCreate]", |
| 195 | CN_SUCCESS == cnDeviceGetAttribute(&cluster_num, |
| 196 | CN_DEVICE_ATTRIBUTE_MAX_CLUSTER_COUNT, |
| 197 | mlu_dev)); |
| 198 | INTERNAL_CHECK( |
| 199 | "[mluOpCreate]", |
| 200 | CN_SUCCESS == |
| 201 | cnDeviceGetAttribute(&core_num_per_cluster, |
| 202 | CN_DEVICE_ATTRIBUTE_MAX_CORE_COUNT_PER_CLUSTER, |
| 203 | mlu_dev)); |
| 204 | INTERNAL_CHECK( |
| 205 | "[mluOpCreate]", |
| 206 | CN_SUCCESS == cnDeviceGetAttribute(&nram_size, |
| 207 | CN_DEVICE_ATTRIBUTE_NRAM_SIZE_PER_CORE, |
| 208 | mlu_dev)); |
| 209 | INTERNAL_CHECK( |
| 210 | "[mluOpCreate]", |
| 211 | CN_SUCCESS == cnDeviceGetAttribute( |
| 212 | &wram_size, |
| 213 | CN_DEVICE_ATTRIBUTE_WEIGHT_RAM_SIZE_PER_CORE, mlu_dev)); |
| 214 | INTERNAL_CHECK( |
| 215 | "[mluOpCreate]", |
nothing calls this directly
no test coverage detected