*/
aclrtStream stream(int stream) {
if (streams[stream] == nullptr) {
- ggml_cann_set_device(device);
+ // If the device is not set here, destroying the stream later may cause a mismatch
+ // between the thread contexts where the stream was created and destroyed.
+ // However, I printed the device_id, thread_id, and stream, and they are all consistent.
+ ACL_CHECK(aclrtSetDevice(device));
ACL_CHECK(aclrtCreateStream(&streams[stream]));
}
return streams[stream];
* @param device The device ID to set.
*/
void ggml_cann_set_device(const int32_t device) {
- // TODO: uncomment these lines after empty context has fixed.
- // int current_device;
- // ACL_CHECK(aclrtGetDevice(¤t_device));
+ int current_device = -1;
+ aclrtGetDevice(¤t_device);
- // if (device == current_device) {
- // return;
- // }
+ if (device == current_device) {
+ return;
+ }
ACL_CHECK(aclrtSetDevice(device));
}
ggml_cann_get_rows(ctx, dst);
break;
case GGML_OP_SET_ROWS:
+ std::cout << "lcg GGML_OP_SET_ROWS"<< std::endl;
ggml_cann_set_rows(ctx, dst);
break;
case GGML_OP_DUP: