Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Auto Parallel] Add C++ DeviceMesh #44951

Merged
merged 3 commits into from
Aug 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions paddle/fluid/distributed/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@ add_subdirectory(ps)
add_subdirectory(test)
add_subdirectory(index_dataset)
add_subdirectory(fleet_executor)
add_subdirectory(auto_parallel)
40 changes: 40 additions & 0 deletions paddle/fluid/distributed/auto_parallel/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
cc_library(
device_mesh
SRCS device_mesh.cc
DEPS auto_parallel_proto)
cc_test(
device_mesh_test
SRCS device_mesh_test.cc
DEPS device_mesh)

# cc_library(
# process_mesh
# SRCS process_mesh.cc
# DEPS auto_parallel_proto)
# cc_test(
# process_mesh_test
# SRCS process_mesh_test.cc
# DEPS process_mesh)

# cc_library(
# dist_attr
# SRCS dist_attr.cc
# DEPS process_mesh auto_parallel_proto proto_desc)
# cc_test(
# dist_attr_test
# SRCS dist_attr_test.cc
# DEPS dist_attr)

# cc_library(
# dist_mapper
# SRCS dist_mapper.cc
# DEPS device_mesh auto_parallel_proto)
# cc_test(
# dist_mapper_test
# SRCS dist_mapper_test.cc
# DEPS dist_mapper)

proto_library(auto_parallel_proto SRCS auto_parallel.proto)

# cc_library(auto_parallel DEPS process_mesh device_mesh dist_attr dist_mapper
# auto_parallel_proto)
88 changes: 88 additions & 0 deletions paddle/fluid/distributed/auto_parallel/auto_parallel.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless optional by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */

syntax = "proto2";

package paddle.distributed.auto_parallel;

// This proto describes the capability of one device such as the computation and memory.
message DeviceCapabilityProto {
optional double single_precision_flops = 1;

optional double double_precision_flops = 2;

optional double memory_size_in_bytes = 3;

optional double clock_rate_in_ghz = 4;
}

// This proto represents a device.
message DeviceProto {
// The global id of this device within the cluster.
optional int64 global_id = 1;

// The local id of this device within the machine.
optional int64 local_id = 2;

// The id of the machine own this device.
optional int64 machine_id = 3;

// The id of the machine has this device.
optional string type = 4;

// The capability of this device.
optional DeviceCapabilityProto capability = 5;
}

// This proto describes the capability of the link between two devices.
message LinkCapabilityProto {
optional int64 bandwidth = 1; // Bytes/s
optional int64 latency = 2;
}

message LinkProto {
// The global id of the source device.
optional int64 source_id = 1;

// The global id of the source device.
optional int64 target_id = 2;

// Represent the link type.
optional string type = 3;

// The capability of this link.
optional LinkCapabilityProto capability = 4;
}

// DeviceMesh is used to organize devices and like n-dimension array.
message DeviceMeshProto {
// The global id of this mesh.
optional string name = 1;

// The size of each dimension.
repeated int64 shape = 2;

// These device ids are stored by a row-major way.
// There are no duplicate device ids within one device mesh.
repeated int64 device_ids = 3;

// The name of each dimension.
repeated string dim_names = 4;

// The devices of this mesh.
repeated DeviceProto devices = 5;

// The links are between devices.
repeated LinkProto links = 6;
}
Loading