Skip to content

Commit

Permalink
Add another thread pool to deal with the lockfree data trans
Browse files Browse the repository at this point in the history
  • Loading branch information
jcf94 committed Nov 23, 2018
1 parent fdb41e3 commit 18bc926
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
# ***********************************************

CC = g++
CFLAGS += -std=c++14
CFLAGS += -std=c++11

LD = g++
LDFLAGS += -std=c++14
LDFLAGS += -std=c++11

#NAME = $(wildcard *.cpp)
NAME = benchmark.cpp
Expand Down
15 changes: 14 additions & 1 deletion src/rdma_channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ RDMA_Channel::RDMA_Channel(RDMA_Endpoint* endpoint, ibv_pd* pd, ibv_qp* qp)
return;
}

nolock_pool_ = new ThreadPool(DEFAULT_NOLOCK_POOL_THREADS);
if (nolock_pool_)
{
log_info("ThreadPool Created");
} else
{
log_error("Failed to create ThreadPool");
return;
}

log_info("RDMA_Channel Created");
}

Expand All @@ -56,6 +66,9 @@ RDMA_Channel::~RDMA_Channel()
unlock_pool_->wait();
delete unlock_pool_;

nolock_pool_->wait();
delete nolock_pool_;

delete incoming_;
delete outgoing_;

Expand Down Expand Up @@ -239,7 +252,7 @@ void RDMA_Channel::task_with_lock(std::function<void()> &&task)

void RDMA_Channel::task_without_lock(std::function<void()> &&task)
{
work_pool_->add_task([this, task_run = std::move(task)]
nolock_pool_->add_task([this, task_run = std::move(task)]
{
task_run();
});
Expand Down
8 changes: 5 additions & 3 deletions src/rdma_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ PROG : RDMA_CHANNEL_H
#include <functional>
#include <infiniband/verbs.h>

#define DEFAULT_TOTAL_POOL_THREADS 8
#define DEFAULT_WORK_POOL_THREADS 6
#define DEFAULT_UNLOCK_POOL_THREADS (DEFAULT_TOTAL_POOL_THREADS - DEFAULT_WORK_POOL_THREADS)
#define DEFAULT_TOTAL_POOL_THREADS 10
#define DEFAULT_WORK_POOL_THREADS 4
#define DEFAULT_UNLOCK_POOL_THREADS 2
#define DEFAULT_NOLOCK_POOL_THREADS (DEFAULT_TOTAL_POOL_THREADS - DEFAULT_WORK_POOL_THREADS - DEFAULT_UNLOCK_POOL_THREADS)

enum Channel_status
{
Expand Down Expand Up @@ -98,6 +99,7 @@ class RDMA_Channel
// ThreadPool used for data process
ThreadPool* work_pool_ = NULL;
ThreadPool* unlock_pool_ = NULL;
ThreadPool* nolock_pool_ = NULL;

//Data count
uint64_t total_recv_data_ = 0;
Expand Down
6 changes: 3 additions & 3 deletions src/rdma_message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,15 @@ void RDMA_Message::process_attached_message(const ibv_wc &wc, RDMA_Session* sess
Message_Content msg = RDMA_Message::parse_message_content((char*)channel->incoming()->buffer());
send_message_to_channel(channel, RDMA_MESSAGE_ACK);

// channel->task_without_lock([channel, msg]
// {
channel->task_without_lock([channel, msg]
{
RDMA_Buffer* test_new = new RDMA_Buffer(channel, channel->pd(), msg.buffer_size);

channel->insert_to_table((uint64_t)test_new, (uint64_t)msg.remote_addr
);

channel->read_data(test_new, msg);
// });
});

break;
}
Expand Down
2 changes: 2 additions & 0 deletions src/rdma_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ PROG : RDMA_UTIL_CPP

#include "rdma_util.h"

#include <stdexcept>

std::string make_string(const char *fmt, ...)
{
char * sz;
Expand Down

0 comments on commit 18bc926

Please sign in to comment.