Skip to content

Commit 973823c

Browse files
committed
send/resp:通信增加了返回确认
1 parent 8d4e742 commit 973823c

3 files changed

Lines changed: 17 additions & 6 deletions

File tree

excuter/op-mem-ompsimd/src/client/main.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,22 @@ int main()
2020

2121
server.func = [&mem, &opfactory, &memmutex](const char *buffer)->std::string
2222
{
23+
24+
2325
deepx::op::Op op;
2426
op.recv_at = chrono::system_clock::now();
2527
op.load(buffer);
28+
std::string resp=to_string(op.id);
29+
resp+=" recv_at:";
30+
resp+=to_string(op.recv_at.time_since_epoch().count());
2631
if (opfactory.ops.find(op.name)==opfactory.ops.end()){
2732
cout<<"<op> "<<op.name<<" not found"<<endl;
28-
return "error";
33+
resp+="error op not found";
2934
}
3035
auto &type_map = opfactory.ops.find(op.name)->second;
3136
if (type_map.find(op.dtype)==type_map.end()){
3237
cout<<"<op>"<<op.name<<" "<<op.dtype<<" not found"<<endl;
33-
return "error";
38+
resp+="error dtype not found";
3439
}
3540
auto src = type_map.find(op.dtype)->second;
3641

@@ -42,7 +47,8 @@ int main()
4247
(*src).forward(mem);
4348
}
4449
memmutex.unlock();
45-
return to_string(op.id);
50+
resp+=" success";
51+
return resp;
4652
};
4753
server.start();
4854
return 0;

front/py/deepx/nn/deepxir.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from typing import Tuple, List, Optional
22
import time
33

4-
_id_counter=0
54
class DeepxIR:
65
def __init__(self,
76
name:str,
@@ -39,7 +38,7 @@ def __init__(self,
3938
self._grad = grad
4039
self._args_grad = args_grad if grad else []
4140
self._returns_grad = returns_grad if grad else []
42-
self._id=++_id_counter
41+
self._id=None
4342
self._created_at=time.time()
4443
self._sent_at=None
4544

front/py/deepx/scheduler/client/allclient.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
import time
55
default_client = _default_udpconn
66

7+
8+
_id_counter=0
79
def send(ir:DeepxIR) -> Optional[dict]:
810
ir._sent_at=time.time()
9-
return default_client.send(str(ir))
11+
global _id_counter
12+
_id_counter=_id_counter+1
13+
ir._id=_id_counter
14+
resp=default_client.send(str(ir))
15+
print(resp)

0 commit comments

Comments
 (0)