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
|
||||
// \return worker table pointer if this node is worker
|
||||
// otherwise return nullptr
|
||||
template <typename EleType, typename OptionType>
|
||||
typename trait::OptionTrait<EleType, OptionType>::WorkerTableType*
|
||||
MV_CreateTable(const OptionType& option) {
|
||||
auto table = table_factory::CreateTable<EleType>(option);
|
||||
template <typename TableOptionType>
|
||||
typename TableOptionType::WorkerTableType*
|
||||
MV_CreateTable(const TableOptionType& option) {
|
||||
auto table = table_factory::CreateTable(option);
|
||||
Zoo::Get()->Barrier();
|
||||
return table;
|
||||
}
|
||||
|
|
|
@ -7,15 +7,14 @@
|
|||
|
||||
namespace multiverso {
|
||||
|
||||
struct ArrayTableOption {
|
||||
size_t size;
|
||||
};
|
||||
template<typename EleType>
|
||||
struct ArrayTableOption;
|
||||
|
||||
template <typename T>
|
||||
class ArrayWorker : public WorkerTable {
|
||||
public:
|
||||
explicit ArrayWorker(size_t size);
|
||||
explicit ArrayWorker(const ArrayTableOption &option);
|
||||
explicit ArrayWorker(const ArrayTableOption<T> &option);
|
||||
// std::vector<T>& raw() { return table_; }
|
||||
|
||||
// Get all element, data is user-allocated memory
|
||||
|
@ -44,7 +43,7 @@ template <typename T>
|
|||
class ArrayServer : public ServerTable {
|
||||
public:
|
||||
explicit ArrayServer(size_t size);
|
||||
explicit ArrayServer(const ArrayTableOption& option);
|
||||
explicit ArrayServer(const ArrayTableOption<T> &option);
|
||||
|
||||
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_;
|
||||
};
|
||||
|
||||
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_
|
||||
|
|
|
@ -74,24 +74,6 @@ protected:
|
|||
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_
|
||||
|
|
|
@ -10,25 +10,23 @@ namespace multiverso {
|
|||
|
||||
namespace table_factory {
|
||||
|
||||
template <typename EleType, typename OptionType>
|
||||
typename trait::OptionTrait<EleType, OptionType>::WorkerTableType*
|
||||
CreateTable(const OptionType& option) {
|
||||
void FreeServerTables();
|
||||
void PushServerTable(ServerTable*table);
|
||||
|
||||
template <typename OptionType>
|
||||
typename OptionType::WorkerTableType* CreateTable(const OptionType& option) {
|
||||
if (Zoo::Get()->server_rank() >= 0) {
|
||||
table_factory::PushServerTable(
|
||||
new trait::OptionTrait<EleType, OptionType>::ServerTableType(option));
|
||||
PushServerTable(
|
||||
new typename OptionType::ServerTableType(option));
|
||||
}
|
||||
if (Zoo::Get()->worker_rank() >= 0) {
|
||||
return reinterpret_cast<trait::OptionTrait<EleType, OptionType>::WorkerTableType*>
|
||||
(new trait::OptionTrait<EleType, OptionType>::WorkerTableType(option));
|
||||
return new typename OptionType::WorkerTableType(option);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void FreeServerTables();
|
||||
void PushServerTable(ServerTable*table);
|
||||
|
||||
} // namespace table_factory
|
||||
|
||||
} // namespace multiverso
|
||||
|
||||
#endif // MULTIVERSO_TABLE_FACTORY_H_
|
||||
#endif // MULTIVERSO_TABLE_FACTORY_H_
|
||||
|
|
|
@ -71,20 +71,10 @@ public:
|
|||
std::vector<Blob>* result) = 0;
|
||||
};
|
||||
|
||||
namespace trait {
|
||||
template<typename EleType, typename OptionType>
|
||||
struct OptionTrait;
|
||||
}
|
||||
|
||||
#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; \
|
||||
}; \
|
||||
}
|
||||
#define DEFINE_TABLE_TYPE(template_type, \
|
||||
worker_table_type, server_table_type) \
|
||||
typedef worker_table_type<template_type> WorkerTableType; \
|
||||
typedef server_table_type<template_type> ServerTableType;
|
||||
|
||||
} // namespace multiverso
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ public:
|
|||
MemoryBlock* next;
|
||||
private:
|
||||
char* data_;
|
||||
std::atomic<int> ref_ = 0;
|
||||
std::atomic<int> ref_;
|
||||
static const size_t header_size_ = (sizeof(MemoryBlock*) << 1);
|
||||
};
|
||||
|
||||
|
@ -60,4 +60,4 @@ private:
|
|||
|
||||
} // namespace multiverso
|
||||
|
||||
#endif // MULTIVERSO_ALLOCATOR_H_
|
||||
#endif // MULTIVERSO_ALLOCATOR_H_
|
||||
|
|
Двоичные данные
Source/Multiverso/x64/release/libmultiverso.a
Двоичные данные
Source/Multiverso/x64/release/libmultiverso.a
Двоичный файл не отображается.
Загрузка…
Ссылка в новой задаче