提交 05b3196e 编写于 作者: L liaogang

clang-format

上级 d8c8f419
......@@ -4,41 +4,29 @@ namespace majel {
namespace detail {
class PlacePrinter
: public boost::static_visitor<> {
class PlacePrinter : public boost::static_visitor<> {
private:
std::ostream& os_;
public:
PlacePrinter(std::ostream& os) : os_(os) {}
void operator()(const CpuPlace&) {
os_ << "CpuPlace";
}
void operator()(const CpuPlace&) { os_ << "CpuPlace"; }
void operator()(const GpuPlace& p) {
os_ << "GpuPlace(" << p.device << ")";
}
void operator()(const GpuPlace& p) { os_ << "GpuPlace(" << p.device << ")"; }
};
} // namespace majel
static Place the_default_place;
void set_place(const Place& place) {
the_default_place = place;
}
void set_place(const Place& place) { the_default_place = place; }
const Place& get_place() {
return the_default_place;
}
const Place& get_place() { return the_default_place; }
const GpuPlace default_gpu() {
return GpuPlace(0);
}
const GpuPlace default_gpu() { return GpuPlace(0); }
const CpuPlace default_cpu() {
return CpuPlace();
}
const CpuPlace default_cpu() { return CpuPlace(); }
bool is_gpu_place(const Place& p) {
return boost::apply_visitor(IsGpuPlace(), p);
......
#include "gtest/gtest.h"
#include "majel/place.h"
#include <sstream>
#include "gtest/gtest.h"
TEST(Place, Equality) {
majel::CpuPlace cpu;
......@@ -18,12 +18,12 @@ TEST(Place, Equality) {
}
TEST(Place, Default) {
EXPECT_TRUE(majel::is_gpu_place( majel::get_place()));
EXPECT_TRUE(majel::is_gpu_place( majel::default_gpu()));
EXPECT_TRUE(majel::is_cpu_place( majel::default_cpu()));
EXPECT_TRUE(majel::is_gpu_place(majel::get_place()));
EXPECT_TRUE(majel::is_gpu_place(majel::default_gpu()));
EXPECT_TRUE(majel::is_cpu_place(majel::default_cpu()));
majel::set_place(majel::CpuPlace());
EXPECT_TRUE(majel::is_cpu_place( majel::get_place()));
EXPECT_TRUE(majel::is_cpu_place(majel::get_place()));
}
TEST(Place, Print) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册