Skip to content

Commit 9a127aa

Browse files
committed
1. remove static
2. fix warning
1 parent 9d1673e commit 9a127aa

File tree

13 files changed

+31
-28
lines changed

13 files changed

+31
-28
lines changed

include/Comm/Comm_Assemble/Comm_Assemble.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
#pragma once
77

8-
#include "../Comm_Keys/Comm_Keys_31-sr.h"
8+
#include "../Comm_Keys/Comm_Keys_31-gather.h"
99
#include "../Comm_Trans/Comm_Trans.h"
1010
#include "../Comm_Tools.h"
1111

include/Comm/Comm_Trans/Comm_Trans.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class Comm_Trans
6666
int comm_size = 1;
6767

6868
private:
69-
const static int tag_data = 0;
69+
const int tag_data = 0;
7070
};
7171

7272
}

include/Comm/Comm_Trans/Comm_Trans.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ void Comm_Trans<Tkey,Tvalue,Tdatas_isend,Tdatas_recv>::communicate(
8484
int flag_iprobe=0;
8585
MPI_Status status_recv;
8686
MPI_Message message_recv;
87-
MPI_CHECK (MPI_Improbe(MPI_ANY_SOURCE, Comm_Trans::tag_data, this->mpi_comm, &flag_iprobe, &message_recv, &status_recv));
87+
MPI_CHECK (MPI_Improbe(MPI_ANY_SOURCE, this->tag_data, this->mpi_comm, &flag_iprobe, &message_recv, &status_recv));
8888
if (flag_iprobe && rank_recv_working!=status_recv.MPI_SOURCE && memory_enough(memory_max_recv))
8989
{
9090
futures_recv[status_recv.MPI_SOURCE] = std::async (std::launch::async,
@@ -135,7 +135,7 @@ void Comm_Trans<Tkey,Tvalue,Tdatas_isend,Tdatas_recv>::isend_data(
135135
const std::size_t exponent_align = Cereal_Func::align_stringstream(ss_isend);
136136
str_isend = ss_isend.str();
137137
memory_max_isend.store( std::max(str_isend.size()*sizeof(char), memory_max_isend.load()) );
138-
Cereal_Func::mpi_isend(str_isend, exponent_align, rank_isend, Comm_Trans::tag_data, this->mpi_comm, request_isend);
138+
Cereal_Func::mpi_isend(str_isend, exponent_align, rank_isend, this->tag_data, this->mpi_comm, request_isend);
139139
}
140140

141141

include/Comm/global/Cereal_Func.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ namespace Comm
1515
namespace Cereal_Func
1616
{
1717
// Send str
18-
extern void mpi_send(const std::string &str, const std::size_t exponent_align, const int rank_recv, const int tag, const MPI_Comm &mpi_comm);
18+
extern inline void mpi_send(const std::string &str, const std::size_t exponent_align, const int rank_recv, const int tag, const MPI_Comm &mpi_comm);
1919

2020
// Send data
2121
template<typename... Ts>
2222
extern void mpi_send(const int rank_recv, const int tag, const MPI_Comm &mpi_comm,
2323
const Ts&... data);
2424

2525
// Isend str
26-
extern void mpi_isend(const std::string &str, const std::size_t exponent_align, const int rank_recv, const int tag, const MPI_Comm &mpi_comm, MPI_Request &request);
26+
extern inline void mpi_isend(const std::string &str, const std::size_t exponent_align, const int rank_recv, const int tag, const MPI_Comm &mpi_comm, MPI_Request &request);
2727

2828
// Isend data using temporary memory str
2929
template<typename... Ts>
@@ -33,11 +33,14 @@ namespace Cereal_Func
3333

3434
// Recv to data
3535
template<typename... Ts>
36-
MPI_Status mpi_recv(const MPI_Comm &mpi_comm,
36+
extern MPI_Status mpi_recv(const MPI_Comm &mpi_comm,
3737
Ts&... data);
3838

3939
// Mrecv to return
40-
extern std::vector<char> mpi_mrecv(MPI_Message &message_recv, const MPI_Status &status);
40+
extern inline std::vector<char> mpi_mrecv(MPI_Message &message_recv, const MPI_Status &status);
41+
42+
// every 2^exponent_align char concatenate to 1 word
43+
extern inline std::size_t align_stringstream(std::stringstream &ss);
4144
}
4245

4346
}

include/Comm/global/Cereal_Func.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace Cereal_Func
2424
// every 2^exponent_align char concatenate to 1 word
2525
// <<exponent_align means *2^exponent_align
2626
// >>exponent_align means /2^exponent_align
27-
static std::size_t align_stringstream(std::stringstream &ss)
27+
inline std::size_t align_stringstream(std::stringstream &ss)
2828
{
2929
#if MPI_VERSION>=4
3030
using int_type = MPI_Count;
@@ -34,18 +34,18 @@ namespace Cereal_Func
3434
const std::size_t size_old = ss.str().size(); // Inefficient, should be optimized
3535
const std::size_t times = std::ceil( double(size_old) / double(std::numeric_limits<int_type>::max()) );
3636
const std::size_t exponent_align = std::ceil( std::log(times) / std::log(2) );
37-
const MPI_Datatype MPI_type = MPI_Wrapper::char_contiguous(exponent_align);
37+
MPI_Wrapper::char_contiguous(exponent_align);
3838
constexpr char c0 = 0;
3939
const std::size_t size_align = 1<<exponent_align;
4040
if(size_old%size_align)
41-
for(int i=size_old%size_align; i<size_align; ++i)
41+
for(std::size_t i=size_old%size_align; i<size_align; ++i)
4242
ss<<c0;
4343
return exponent_align;
4444
}
4545

4646

4747
// Send str
48-
static void mpi_send(const std::string &str, const std::size_t exponent_align, const int rank_recv, const int tag, const MPI_Comm &mpi_comm)
48+
inline void mpi_send(const std::string &str, const std::size_t exponent_align, const int rank_recv, const int tag, const MPI_Comm &mpi_comm)
4949
{
5050
#if MPI_VERSION>=4
5151
MPI_CHECK( MPI_Send_c( str.c_str(), str.size()>>exponent_align, MPI_Wrapper::char_contiguous(exponent_align), rank_recv, tag, mpi_comm ) );
@@ -71,7 +71,7 @@ namespace Cereal_Func
7171

7272

7373
// Isend str
74-
static void mpi_isend(const std::string &str, const std::size_t exponent_align, const int rank_recv, const int tag, const MPI_Comm &mpi_comm, MPI_Request &request)
74+
inline void mpi_isend(const std::string &str, const std::size_t exponent_align, const int rank_recv, const int tag, const MPI_Comm &mpi_comm, MPI_Request &request)
7575
{
7676
#if MPI_VERSION>=4
7777
MPI_CHECK( MPI_Isend_c( str.c_str(), str.size()>>exponent_align, MPI_Wrapper::char_contiguous(exponent_align), rank_recv, tag, mpi_comm, &request ) );
@@ -98,7 +98,7 @@ namespace Cereal_Func
9898

9999

100100
// Recv to return
101-
static std::vector<char> mpi_recv(const MPI_Comm &mpi_comm, MPI_Status &status)
101+
inline std::vector<char> mpi_recv(const MPI_Comm &mpi_comm, MPI_Status &status)
102102
{
103103
for(std::size_t exponent_align=0; ; ++exponent_align)
104104
{
@@ -142,7 +142,7 @@ namespace Cereal_Func
142142

143143

144144
// Mrecv to return
145-
static std::vector<char> mpi_mrecv(MPI_Message &message_recv, const MPI_Status &status)
145+
inline std::vector<char> mpi_mrecv(MPI_Message &message_recv, const MPI_Status &status)
146146
{
147147
for(std::size_t exponent_align=0; ; ++exponent_align)
148148
{

include/Comm/global/Global_Func.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace Comm
1010

1111
namespace Global_Func
1212
{
13-
static std::size_t memory_available();
13+
extern inline std::size_t memory_available();
1414
}
1515

1616
}

include/Comm/global/Global_Func.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace Comm
1616

1717
namespace Global_Func
1818
{
19-
static std::size_t memory_available()
19+
inline std::size_t memory_available()
2020
{
2121
constexpr std::size_t kB_to_B = 1024;
2222
std::ifstream ifs("/proc/meminfo");

include/Comm/global/MPI_Wrapper.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ namespace MPI_Wrapper
6060
{
6161
const std::size_t size_old = type_pool.size();
6262
type_pool.resize(exponent+1);
63-
for(int ie=size_old; ie<type_pool.size(); ++ie)
63+
for(std::size_t ie=size_old; ie<type_pool.size(); ++ie)
6464
{
6565
if(!ie)
6666
{
@@ -77,7 +77,7 @@ namespace MPI_Wrapper
7777
}
7878
~MPI_Type_Contiguous_Pool()
7979
{
80-
for(int ie=1; ie<type_pool.size(); ++ie)
80+
for(std::size_t ie=1; ie<type_pool.size(); ++ie)
8181
MPI_Type_free( &type_pool[ie] );
8282
}
8383
std::vector<MPI_Datatype> type_pool;

unittests/Comm_Assemble/Communicate_Map-test-2.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
namespace Communicate_Map_Test
2525
{
26-
void test_assemble(int argc, char *argv[])
26+
static void test_assemble(int argc, char *argv[])
2727
{
2828
int provided;
2929
MPI_CHECK( MPI_Init_thread( &argc, &argv, MPI_THREAD_MULTIPLE, &provided ) );

unittests/Comm_Assemble/Communicate_Map-test-speed.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
namespace Communicate_Map_Test
2929
{
30-
void test_speed(int argc, char *argv[])
30+
static void test_speed(int argc, char *argv[])
3131
{
3232
int provided;
3333
MPI_CHECK( MPI_Init_thread( &argc, &argv, MPI_THREAD_MULTIPLE, &provided ) );

0 commit comments

Comments
 (0)