[BugFix] replace ftok with custom_ftok in get_output/save_output ops (#6822)

* [BugFix] replace ftok with custom_ftok in get_output/save_output ops

* [Test] add unit test for custom_ftok

* [Chore] create custom_ftok.h

* [Chore] reorganize header file

* [Fix] fix cache messager msg_queue_id+rank_id conflict
This commit is contained in:
Yonghua Li
2026-03-16 14:22:18 +08:00
committed by GitHub
parent 4d39232553
commit 7c8c0a3c02
24 changed files with 126 additions and 34 deletions
+4 -6
View File
@@ -17,6 +17,7 @@
#include <sys/ipc.h>
#include <sys/msg.h>
#include <sys/types.h>
#include "custom_ftok.h"
#include "msg_utils.h"
#include "paddle/extension.h"
@@ -33,9 +34,9 @@ void GetOutputKVSignal(const paddle::Tensor& x,
std::string msg_que_str(msg_que_str_tmp);
msg_queue_id = std::stoi(msg_que_str);
}
msg_queue_id += rank_id;
msg_queue_id = msg_queue_id << 4 + rank_id;
static struct msgdatakv msg_rcv;
static key_t key = ftok("/opt/", msg_queue_id);
static key_t key = custom_ftok("/opt/", msg_queue_id);
static int msgid = msgget(key, IPC_CREAT | 0666);
int* out_data = const_cast<int*>(x.data<int>());
@@ -77,10 +78,7 @@ void GetOutputEp(const paddle::Tensor& x,
#ifdef GET_OUTPUT_DEBUG
std::cout << "msg_queue_id is: " << msg_queue_id << std::endl;
#endif
// static key_t key = ftok("/dev/shm", msg_queue_id);
// static int msgid = msgget(key, IPC_CREAT | 0666);
key_t key = ftok("/dev/shm", msg_queue_id);
key_t key = custom_ftok("/dev/shm", msg_queue_id);
int msgid = msgget(key, IPC_CREAT | 0666);
#ifdef GET_OUTPUT_DEBUG