Skip to content

Commit

Permalink
"Include what you use" fixes for some xls/synthesis/... targets.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 554982685
  • Loading branch information
tcal-x authored and copybara-github committed Aug 8, 2023
1 parent 5ea01c8 commit 916686b
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 13 deletions.
3 changes: 1 addition & 2 deletions xls/synthesis/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,8 @@ cc_binary(
":synthesis_service_cc_grpc",
"//xls/common:init_xls",
"//xls/common/logging",
"//xls/common/status:status_macros",
"@com_github_grpc_grpc//:grpc++",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/time",
],
Expand Down
21 changes: 14 additions & 7 deletions xls/synthesis/fake_synthesis_server_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,26 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "absl/status/statusor.h"
#include <cstdint>
#include <cstdlib>
#include <memory>
#include <string>

#include "absl/flags/flag.h"
#include "absl/strings/str_cat.h"
#include "absl/time/clock.h"
#include "absl/time/time.h"
#include "grpcpp/grpcpp.h"
#include "grpcpp/security/server_credentials.h"
#include "grpcpp/server.h"
#include "grpcpp/server_builder.h"
#include "grpcpp/server_context.h"
#include "grpcpp/support/status.h"
#include "xls/common/init_xls.h"
#include "xls/common/logging/logging.h"
#include "xls/common/status/status_macros.h"
#include "xls/synthesis/credentials.h"
#include "xls/synthesis/synthesis.pb.h"
#include "xls/synthesis/synthesis_service.grpc.pb.h"
#include "grpcpp/support/status_code_enum.h"

const char kUsage[] = R"(
Launches a XLS synthesis server which serves fake results. The flag
Expand Down Expand Up @@ -59,10 +65,11 @@ class FakeSynthesisServiceImpl : public SynthesisService::Service {
CompileResponse* result) override {
auto start = absl::Now();

result->set_slack_ps(request->target_frequency_hz() <= max_frequency_hz_
? 0
: 1e12L / request->target_frequency_hz() -
1e12L / max_frequency_hz_);
result->set_slack_ps(
request->target_frequency_hz() <= max_frequency_hz_
? 0
: static_cast<int64_t>(1e12L / request->target_frequency_hz() -
1e12L / max_frequency_hz_));
result->set_power(42);
result->set_area(123);
result->set_netlist("// NETLIST");
Expand Down
5 changes: 5 additions & 0 deletions xls/synthesis/openroad/json_metrics_server_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""Tests of the synthesis service: client and dummy server."""

import subprocess
import time

import portpicker

Expand Down Expand Up @@ -45,6 +46,10 @@ def _start_server(self, args):
port = portpicker.pick_unused_port()
proc = subprocess.Popen([runfiles.get_path(SERVER_PATH), f'--port={port}'] +
args)

# workaround: allow some time for the server to open the port
time.sleep(1)

return port, proc

def test_slack(self):
Expand Down
6 changes: 3 additions & 3 deletions xls/synthesis/synthesis_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "xls/synthesis/synthesis_client.h"

#include <memory>
#include <string>

#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "grpcpp/support/status.h"
#include "grpcpp/channel.h"
#include "grpcpp/client_context.h"
#include "grpcpp/create_channel.h"
#include "grpcpp/security/credentials.h"
#include "grpcpp/support/status.h"
#include "xls/common/status/status_macros.h"
#include "xls/synthesis/credentials.h"
#include "xls/synthesis/synthesis_client.h"
#include "xls/synthesis/synthesis.pb.h"
#include "xls/synthesis/synthesis_service.grpc.pb.h"


namespace xls {
namespace synthesis {

Expand Down
1 change: 0 additions & 1 deletion xls/synthesis/synthesis_client_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// limitations under the License.

#include <cstdint>
#include <cstdlib>
#include <iostream>
#include <string>
#include <string_view>
Expand Down

0 comments on commit 916686b

Please sign in to comment.