Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pingpong apps capable of measuring latency #248

Merged
merged 5 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions media-proxy/include/proxy_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include "session-mtl.h"
#include "session-rdma.h"
#include <mutex>

#pragma once

Expand All @@ -34,6 +35,7 @@ class ProxyContext {
std::vector<Session *> mDpCtx;
mtl_handle mDevHandle = NULL;
libfabric_ctx *mDevHandle_rdma = NULL;
std::mutex ctx_mtx;

bool imtl_init_preparing;
pthread_mutex_t mutex_lock;
Expand Down
4 changes: 3 additions & 1 deletion media-proxy/src/api_server_tcp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,13 @@ void* msg_loop(void* ptr)
DEBUG("MCM_QUERY_MEMIF_ID: Case entry.");
/* TODO: return memdif ID */
break;
case MCM_QUERY_MEMIF_PARAM:
case MCM_QUERY_MEMIF_PARAM: {
DEBUG("MCM_QUERY_MEMIF_PARAM: Case entry.");
if (buffer == NULL || msg.command.data_len < 4) {
INFO("Invalid parameters.");
break;
}
std::lock_guard<std::mutex> lock(proxy_ctx->ctx_mtx);
session_id = *(uint32_t*)buffer;
for (auto it : proxy_ctx->mDpCtx) {
if (it->get_id() == session_id) {
Expand All @@ -154,6 +155,7 @@ void* msg_loop(void* ptr)
}
}
break;
}
case MCM_DESTROY_SESSION:
DEBUG("MCM_DESTROY_SESSION: Case entry.");
if (buffer == NULL || msg.command.data_len < 4) {
Expand Down
5 changes: 5 additions & 0 deletions media-proxy/src/proxy_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ int ProxyContext::RxStart_rdma(const mcm_conn_param *request)
}

INFO("%s, session id: %d", __func__, session_ptr->get_id());
std::lock_guard<std::mutex> lock(ctx_mtx);
mDpCtx.push_back(session_ptr);
return session_ptr->get_id();
}
Expand Down Expand Up @@ -251,6 +252,7 @@ int ProxyContext::RxStart_mtl(const mcm_conn_param *request)
}

INFO("%s, session id: %d", __func__, session_ptr->get_id());
std::lock_guard<std::mutex> lock(ctx_mtx);
mDpCtx.push_back(session_ptr);
return session_ptr->get_id();
}
Expand Down Expand Up @@ -287,6 +289,7 @@ int ProxyContext::TxStart_rdma(const mcm_conn_param *request)
}

INFO("%s, session id: %d", __func__, session_ptr->get_id());
std::lock_guard<std::mutex> lock(ctx_mtx);
mDpCtx.push_back(session_ptr);
return session_ptr->get_id();
}
Expand Down Expand Up @@ -351,6 +354,7 @@ int ProxyContext::TxStart_mtl(const mcm_conn_param *request)
}

INFO("%s, session id: %d", __func__, session_ptr->get_id());
std::lock_guard<std::mutex> lock(ctx_mtx);
mDpCtx.push_back(session_ptr);
return session_ptr->get_id();
}
Expand All @@ -366,6 +370,7 @@ int ProxyContext::TxStart(const mcm_conn_param *request)
int ProxyContext::Stop(const int32_t session_id)
{
int ret = 0;
std::lock_guard<std::mutex> lock(ctx_mtx);
auto ctx = std::find_if(mDpCtx.begin(), mDpCtx.end(),
[session_id](auto it) { return it->get_id() == session_id; });
if (ctx != mDpCtx.end()) {
Expand Down
8 changes: 8 additions & 0 deletions sdk/samples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,11 @@ target_link_libraries(sender_app PRIVATE mcm_dp)
add_executable(recver_app recver_app.c)
target_include_directories(recver_app PRIVATE ../include)
target_link_libraries(recver_app PRIVATE mcm_dp)

add_executable(ping_app ping_app.c pingpong_common.c)
target_include_directories(ping_app PRIVATE ../include)
target_link_libraries(ping_app PRIVATE mcm_dp)

add_executable(pong_app pong_app.c pingpong_common.c)
target_include_directories(pong_app PRIVATE ../include)
target_link_libraries(pong_app PRIVATE mcm_dp)
Loading