From 1cd2c7861a1fd18d7a322911d3138da233603278 Mon Sep 17 00:00:00 2001 From: Joost VandeVondele Date: Fri, 7 Dec 2018 18:29:36 +0100 Subject: [PATCH] [cluster] avoid creating MPI data type. there is no need to make an MPI data type for the sendbuffer, simpler and faster. No functional change --- src/cluster.cpp | 33 ++++++--------------------------- 1 file changed, 6 insertions(+), 27 deletions(-) diff --git a/src/cluster.cpp b/src/cluster.cpp index 34f4c180..ff492b27 100644 --- a/src/cluster.cpp +++ b/src/cluster.cpp @@ -45,33 +45,12 @@ static MPI_Comm TTComm = MPI_COMM_NULL; static MPI_Comm MoveComm = MPI_COMM_NULL; static MPI_Comm StopComm = MPI_COMM_NULL; -static MPI_Datatype TTEntryDatatype = MPI_DATATYPE_NULL; static std::vector TTBuff; static MPI_Datatype MIDatatype = MPI_DATATYPE_NULL; void init() { int thread_support; - constexpr std::array TTblocklens = {1, 1, 1, 1, 1, 1, 1}; - const std::array TTdisps = {offsetof(KeyedTTEntry, first), - offsetof(KeyedTTEntry, second) + offsetof(TTEntry, key16), - offsetof(KeyedTTEntry, second) + offsetof(TTEntry, move16), - offsetof(KeyedTTEntry, second) + offsetof(TTEntry, value16), - offsetof(KeyedTTEntry, second) + offsetof(TTEntry, eval16), - offsetof(KeyedTTEntry, second) + offsetof(TTEntry, genBound8), - offsetof(KeyedTTEntry, second) + offsetof(TTEntry, depth8)}; - const std::array TTtypes = {MPI_UINT64_T, - MPI_UINT16_T, - MPI_UINT16_T, - MPI_INT16_T, - MPI_INT16_T, - MPI_UINT8_T, - MPI_INT8_T}; - const std::array MIdisps = {offsetof(MoveInfo, move), - offsetof(MoveInfo, depth), - offsetof(MoveInfo, score), - offsetof(MoveInfo, rank)}; - MPI_Init_thread(nullptr, nullptr, MPI_THREAD_MULTIPLE, &thread_support); if (thread_support < MPI_THREAD_MULTIPLE) { @@ -85,10 +64,10 @@ void init() { TTBuff.resize(TTSendBufferSize * world_size); - MPI_Type_create_struct(7, TTblocklens.data(), TTdisps.data(), TTtypes.data(), - &TTEntryDatatype); - MPI_Type_commit(&TTEntryDatatype); - + const std::array MIdisps = {offsetof(MoveInfo, move), + offsetof(MoveInfo, depth), + offsetof(MoveInfo, score), + offsetof(MoveInfo, rank)}; MPI_Type_create_hindexed_block(4, 1, MIdisps.data(), MPI_INT, &MIDatatype); MPI_Type_commit(&MIDatatype); @@ -228,8 +207,8 @@ void save(Thread* thread, TTEntry* tte, } // Start next communication - MPI_Iallgather(send_buff.data(), send_buff.size(), TTEntryDatatype, - TTBuff.data(), TTSendBufferSize, TTEntryDatatype, + MPI_Iallgather(send_buff.data(), send_buff.size() * sizeof(KeyedTTEntry), MPI_BYTE, + TTBuff.data(), TTSendBufferSize * sizeof(KeyedTTEntry), MPI_BYTE, TTComm, &req); } }