tools: Multi-thread remote-compile
Considerably speeds up compilation Change-Id: Ic7e04938f79989a15da36999fab1b192aca9619c Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/60214 Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Ben Clayton <bclayton@google.com> Auto-Submit: Ben Clayton <bclayton@google.com> Reviewed-by: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
parent
38c5a28efd
commit
33c997b829
|
@ -20,6 +20,8 @@
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include <thread> // NOLINT
|
||||||
|
|
||||||
#include "tools/src/cmd/remote-compile/compile.h"
|
#include "tools/src/cmd/remote-compile/compile.h"
|
||||||
#include "tools/src/cmd/remote-compile/socket.h"
|
#include "tools/src/cmd/remote-compile/socket.h"
|
||||||
|
|
||||||
|
@ -350,48 +352,50 @@ bool RunServer(std::string port) {
|
||||||
}
|
}
|
||||||
printf("Listening on port %s...\n", port.c_str());
|
printf("Listening on port %s...\n", port.c_str());
|
||||||
while (auto conn = server_socket->Accept()) {
|
while (auto conn = server_socket->Accept()) {
|
||||||
DEBUG("Client connected...");
|
std::thread([=] {
|
||||||
Stream stream{conn.get()};
|
DEBUG("Client connected...");
|
||||||
|
Stream stream{conn.get()};
|
||||||
|
|
||||||
{
|
{
|
||||||
ConnectionRequest req;
|
ConnectionRequest req;
|
||||||
stream >> req;
|
stream >> req;
|
||||||
if (!stream.error.empty()) {
|
if (!stream.error.empty()) {
|
||||||
printf("%s\n", stream.error.c_str());
|
printf("%s\n", stream.error.c_str());
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
ConnectionResponse resp;
|
ConnectionResponse resp;
|
||||||
if (req.protocol_version != kProtocolVersion) {
|
if (req.protocol_version != kProtocolVersion) {
|
||||||
DEBUG("Protocol version mismatch");
|
DEBUG("Protocol version mismatch");
|
||||||
resp.error = "Protocol version mismatch";
|
resp.error = "Protocol version mismatch";
|
||||||
stream << resp;
|
stream << resp;
|
||||||
continue;
|
return;
|
||||||
}
|
|
||||||
stream << resp;
|
|
||||||
}
|
|
||||||
DEBUG("Connection established");
|
|
||||||
{
|
|
||||||
CompileRequest req;
|
|
||||||
stream >> req;
|
|
||||||
if (!stream.error.empty()) {
|
|
||||||
printf("%s\n", stream.error.c_str());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
#ifdef TINT_ENABLE_MSL_COMPILATION_USING_METAL_API
|
|
||||||
if (req.language == SourceLanguage::MSL) {
|
|
||||||
auto result = CompileMslUsingMetalAPI(req.source);
|
|
||||||
CompileResponse resp;
|
|
||||||
if (!result.success) {
|
|
||||||
resp.error = result.output;
|
|
||||||
}
|
}
|
||||||
stream << resp;
|
stream << resp;
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
DEBUG("Connection established");
|
||||||
|
{
|
||||||
|
CompileRequest req;
|
||||||
|
stream >> req;
|
||||||
|
if (!stream.error.empty()) {
|
||||||
|
printf("%s\n", stream.error.c_str());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#ifdef TINT_ENABLE_MSL_COMPILATION_USING_METAL_API
|
||||||
|
if (req.language == SourceLanguage::MSL) {
|
||||||
|
auto result = CompileMslUsingMetalAPI(req.source);
|
||||||
|
CompileResponse resp;
|
||||||
|
if (!result.success) {
|
||||||
|
resp.error = result.output;
|
||||||
|
}
|
||||||
|
stream << resp;
|
||||||
|
return;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
CompileResponse resp;
|
CompileResponse resp;
|
||||||
resp.error = "server cannot compile this type of shader";
|
resp.error = "server cannot compile this type of shader";
|
||||||
stream << resp;
|
stream << resp;
|
||||||
}
|
}
|
||||||
|
}).detach();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue