This commit is contained in:
Qiwei Ye 2016-03-15 06:14:20 +08:00
Родитель 97f3953bc0
Коммит 650200009c
4 изменённых файлов: 33 добавлений и 2 удалений

Просмотреть файл

@ -189,6 +189,7 @@
<ClInclude Include="include\multiverso\util\mt_queue.h" /> <ClInclude Include="include\multiverso\util\mt_queue.h" />
<ClInclude Include="include\multiverso\util\net_util.h" /> <ClInclude Include="include\multiverso\util\net_util.h" />
<ClInclude Include="include\multiverso\util\quantization_util.h" /> <ClInclude Include="include\multiverso\util\quantization_util.h" />
<ClInclude Include="include\multiverso\util\timer.h" />
<ClInclude Include="include\multiverso\util\waiter.h" /> <ClInclude Include="include\multiverso\util\waiter.h" />
<ClInclude Include="include\multiverso\worker.h" /> <ClInclude Include="include\multiverso\worker.h" />
<ClInclude Include="include\multiverso\zoo.h" /> <ClInclude Include="include\multiverso\zoo.h" />

Просмотреть файл

@ -76,6 +76,9 @@
<ClInclude Include="include\multiverso\table\matrix_table.h"> <ClInclude Include="include\multiverso\table\matrix_table.h">
<Filter>include\table</Filter> <Filter>include\table</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="include\multiverso\util\timer.h">
<Filter>util</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Filter Include="include"> <Filter Include="include">

Просмотреть файл

@ -2,6 +2,7 @@
#include <thread> #include <thread>
#include <random> #include <random>
#include <chrono> #include <chrono>
#include <ctime>
#include <mpi.h> #include <mpi.h>
@ -85,6 +86,14 @@ void TestArray(int argc, char* argv[]) {
Log::Info("Create tables OK\n"); Log::Info("Create tables OK\n");
int iter = 1000; int iter = 1000;
auto add_start = std::chrono::high_resolution_clock::now();
auto add_end = std::chrono::high_resolution_clock::now();
auto get_start = std::chrono::high_resolution_clock::now();
auto get_end = std::chrono::high_resolution_clock::now();
double add_total = 0;
double get_total = 0;
add_total += std::chrono::duration<double, std::milli>(add_start - add_end).count();
get_total += std::chrono::duration<double, std::milli>(get_start - get_end).count();
if (argc == 3) iter = atoi(argv[2]); if (argc == 3) iter = atoi(argv[2]);
for (int i = 0; i < iter; ++i) { for (int i = 0; i < iter; ++i) {
@ -97,17 +106,27 @@ void TestArray(int argc, char* argv[]) {
for (int i = 0; i < 1000000; ++i) for (int i = 0; i < 1000000; ++i)
delta[i] = static_cast<float>(i); delta[i] = static_cast<float>(i);
add_start = std::chrono::high_resolution_clock::now();
shared_array->Add(delta.data(), 1000000); shared_array->Add(delta.data(), 1000000);
add_end = std::chrono::high_resolution_clock::now();
Log::Info("Rank %d Add OK\n", MV_Rank());
Log::Info("Rank %d Add OK, using %llf ms.\n", MV_Rank(), std::chrono::duration<double, std::milli>(add_start - add_end).count());
add_total += std::chrono::duration<double, std::milli>(add_start - add_end).count();
get_start = std::chrono::high_resolution_clock::now();
shared_array->Get(data, 1000000); shared_array->Get(data, 1000000);
Log::Info("Rank %d Get OK\n", MV_Rank()); get_end = std::chrono::high_resolution_clock::now();
Log::Info("Rank %d GET OK, using %llf ms.\n", MV_Rank(), std::chrono::duration<double, std::milli>(get_start - get_end).count());
for (int i = 0; i < 10; ++i) for (int i = 0; i < 10; ++i)
std::cout << data[i] << " "; std::cout << std::endl; std::cout << data[i] << " "; std::cout << std::endl;
get_total += std::chrono::duration<double, std::milli>(get_start - get_end).count();
MV_Barrier(); MV_Barrier();
} }
Log::Info("Rank %d GET using %llf ms, ADD using %llf ms.\n", MV_Rank(), get_total, add_total);
MV_ShutDown(); MV_ShutDown();
} }

Просмотреть файл

@ -0,0 +1,8 @@
#ifndef MULTIVERSO_TIMER_H_
#define MULTIVERSO_TIMER_H_
#include <chrono>
#include <ctime>
#endif //MULTIVERSO_TIMER_H_