Merge branch 'qiwye/asgd-exp' of https://github.com/Microsoft/CNTK-exp-private into qiwye/asgd-exp
This commit is contained in:
Коммит
36369b1eee
|
@ -28,10 +28,10 @@ int MV_ServerIdToRank(int server_id);
|
||||||
// \param option for table initiate
|
// \param option for table initiate
|
||||||
// \return worker table pointer if this node is worker
|
// \return worker table pointer if this node is worker
|
||||||
// otherwise return nullptr
|
// otherwise return nullptr
|
||||||
template <typename EleType, typename OptionType>
|
template <typename TableOptionType>
|
||||||
typename trait::OptionTrait<EleType, OptionType>::WorkerTableType*
|
typename TableOptionType::WorkerTableType*
|
||||||
MV_CreateTable(const OptionType& option) {
|
MV_CreateTable(const TableOptionType& option) {
|
||||||
auto table = table_factory::CreateTable<EleType>(option);
|
auto table = table_factory::CreateTable(option);
|
||||||
Zoo::Get()->Barrier();
|
Zoo::Get()->Barrier();
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,15 +7,14 @@
|
||||||
|
|
||||||
namespace multiverso {
|
namespace multiverso {
|
||||||
|
|
||||||
struct ArrayTableOption {
|
template<typename EleType>
|
||||||
size_t size;
|
struct ArrayTableOption;
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class ArrayWorker : public WorkerTable {
|
class ArrayWorker : public WorkerTable {
|
||||||
public:
|
public:
|
||||||
explicit ArrayWorker(size_t size);
|
explicit ArrayWorker(size_t size);
|
||||||
explicit ArrayWorker(const ArrayTableOption &option);
|
explicit ArrayWorker(const ArrayTableOption<T> &option);
|
||||||
// std::vector<T>& raw() { return table_; }
|
// std::vector<T>& raw() { return table_; }
|
||||||
|
|
||||||
// Get all element, data is user-allocated memory
|
// Get all element, data is user-allocated memory
|
||||||
|
@ -44,7 +43,7 @@ template <typename T>
|
||||||
class ArrayServer : public ServerTable {
|
class ArrayServer : public ServerTable {
|
||||||
public:
|
public:
|
||||||
explicit ArrayServer(size_t size);
|
explicit ArrayServer(size_t size);
|
||||||
explicit ArrayServer(const ArrayTableOption& option);
|
explicit ArrayServer(const ArrayTableOption<T> &option);
|
||||||
|
|
||||||
void ProcessAdd(const std::vector<Blob>& data) override;
|
void ProcessAdd(const std::vector<Blob>& data) override;
|
||||||
|
|
||||||
|
@ -62,7 +61,12 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
DEFINE_TABLE_TRAIT_WITH_INIT_OPTION(ArrayTableOption, ArrayWorker, ArrayServer);
|
template<typename T>
|
||||||
|
struct ArrayTableOption {
|
||||||
|
ArrayTableOption(size_t s) : size(s) {}
|
||||||
|
size_t size;
|
||||||
|
DEFINE_TABLE_TYPE(T, ArrayWorker, ArrayServer);
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,17 +122,6 @@ private:
|
||||||
std::unordered_map<Key, Val> table_;
|
std::unordered_map<Key, Val> table_;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Key, typename Val>
|
|
||||||
class KVTableHelper : public TableHelper {
|
|
||||||
protected:
|
|
||||||
WorkerTable* CreateWorkerTable() override{
|
|
||||||
return new KVWorkerTable<Key, Val>();
|
|
||||||
}
|
|
||||||
ServerTable* CreateServerTable() override{
|
|
||||||
return new KVServerTable<Key, Val>();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // MULTIVERSO_KV_TABLE_H_
|
#endif // MULTIVERSO_KV_TABLE_H_
|
||||||
|
|
|
@ -74,24 +74,6 @@ protected:
|
||||||
std::vector<T> storage_;
|
std::vector<T> storage_;
|
||||||
};
|
};
|
||||||
|
|
||||||
//older implementation
|
|
||||||
template <typename T>
|
|
||||||
class MatrixTableHelper : public TableHelper {
|
|
||||||
public:
|
|
||||||
MatrixTableHelper(integer_t num_row, integer_t num_col) : num_row_(num_row), num_col_(num_col){}
|
|
||||||
~MatrixTableHelper() {}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
WorkerTable* CreateWorkerTable() override{
|
|
||||||
return new MatrixWorkerTable<T>(num_row_, num_col_);
|
|
||||||
}
|
|
||||||
ServerTable* CreateServerTable() override{
|
|
||||||
return new MatrixServerTable<T>(num_row_, num_col_);
|
|
||||||
}
|
|
||||||
integer_t num_row_;
|
|
||||||
integer_t num_col_;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // MULTIVERSO_MATRIX_TABLE_H_
|
#endif // MULTIVERSO_MATRIX_TABLE_H_
|
||||||
|
|
|
@ -10,25 +10,23 @@ namespace multiverso {
|
||||||
|
|
||||||
namespace table_factory {
|
namespace table_factory {
|
||||||
|
|
||||||
template <typename EleType, typename OptionType>
|
void FreeServerTables();
|
||||||
typename trait::OptionTrait<EleType, OptionType>::WorkerTableType*
|
void PushServerTable(ServerTable*table);
|
||||||
CreateTable(const OptionType& option) {
|
|
||||||
|
template <typename OptionType>
|
||||||
|
typename OptionType::WorkerTableType* CreateTable(const OptionType& option) {
|
||||||
if (Zoo::Get()->server_rank() >= 0) {
|
if (Zoo::Get()->server_rank() >= 0) {
|
||||||
table_factory::PushServerTable(
|
PushServerTable(
|
||||||
new trait::OptionTrait<EleType, OptionType>::ServerTableType(option));
|
new typename OptionType::ServerTableType(option));
|
||||||
}
|
}
|
||||||
if (Zoo::Get()->worker_rank() >= 0) {
|
if (Zoo::Get()->worker_rank() >= 0) {
|
||||||
return reinterpret_cast<trait::OptionTrait<EleType, OptionType>::WorkerTableType*>
|
return new typename OptionType::WorkerTableType(option);
|
||||||
(new trait::OptionTrait<EleType, OptionType>::WorkerTableType(option));
|
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FreeServerTables();
|
|
||||||
void PushServerTable(ServerTable*table);
|
|
||||||
|
|
||||||
} // namespace table_factory
|
} // namespace table_factory
|
||||||
|
|
||||||
} // namespace multiverso
|
} // namespace multiverso
|
||||||
|
|
||||||
#endif // MULTIVERSO_TABLE_FACTORY_H_
|
#endif // MULTIVERSO_TABLE_FACTORY_H_
|
||||||
|
|
|
@ -71,20 +71,10 @@ public:
|
||||||
std::vector<Blob>* result) = 0;
|
std::vector<Blob>* result) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace trait {
|
#define DEFINE_TABLE_TYPE(template_type, \
|
||||||
template<typename EleType, typename OptionType>
|
worker_table_type, server_table_type) \
|
||||||
struct OptionTrait;
|
typedef worker_table_type<template_type> WorkerTableType; \
|
||||||
}
|
typedef server_table_type<template_type> ServerTableType;
|
||||||
|
|
||||||
#define DEFINE_TABLE_TRAIT_WITH_INIT_OPTION(init_option, \
|
|
||||||
worker_table_type, server_table_type) \
|
|
||||||
namespace trait { \
|
|
||||||
template<typename EleType> \
|
|
||||||
struct OptionTrait<EleType, init_option> { \
|
|
||||||
typedef worker_table_type<EleType> WorkerTableType; \
|
|
||||||
typedef server_table_type<EleType> ServerTableType; \
|
|
||||||
}; \
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace multiverso
|
} // namespace multiverso
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ public:
|
||||||
MemoryBlock* next;
|
MemoryBlock* next;
|
||||||
private:
|
private:
|
||||||
char* data_;
|
char* data_;
|
||||||
std::atomic<int> ref_ = 0;
|
std::atomic<int> ref_;
|
||||||
static const size_t header_size_ = (sizeof(MemoryBlock*) << 1);
|
static const size_t header_size_ = (sizeof(MemoryBlock*) << 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -60,4 +60,4 @@ private:
|
||||||
|
|
||||||
} // namespace multiverso
|
} // namespace multiverso
|
||||||
|
|
||||||
#endif // MULTIVERSO_ALLOCATOR_H_
|
#endif // MULTIVERSO_ALLOCATOR_H_
|
||||||
|
|
Двоичные данные
Source/Multiverso/x64/release/libmultiverso.a
Двоичные данные
Source/Multiverso/x64/release/libmultiverso.a
Двоичный файл не отображается.
Загрузка…
Ссылка в новой задаче