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 <vector>
|
||||
|
||||
#include <thread> // NOLINT
|
||||
|
||||
#include "tools/src/cmd/remote-compile/compile.h"
|
||||
#include "tools/src/cmd/remote-compile/socket.h"
|
||||
|
||||
|
@ -350,6 +352,7 @@ bool RunServer(std::string port) {
|
|||
}
|
||||
printf("Listening on port %s...\n", port.c_str());
|
||||
while (auto conn = server_socket->Accept()) {
|
||||
std::thread([=] {
|
||||
DEBUG("Client connected...");
|
||||
Stream stream{conn.get()};
|
||||
|
||||
|
@ -358,14 +361,14 @@ bool RunServer(std::string port) {
|
|||
stream >> req;
|
||||
if (!stream.error.empty()) {
|
||||
printf("%s\n", stream.error.c_str());
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
ConnectionResponse resp;
|
||||
if (req.protocol_version != kProtocolVersion) {
|
||||
DEBUG("Protocol version mismatch");
|
||||
resp.error = "Protocol version mismatch";
|
||||
stream << resp;
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
stream << resp;
|
||||
}
|
||||
|
@ -375,7 +378,7 @@ bool RunServer(std::string port) {
|
|||
stream >> req;
|
||||
if (!stream.error.empty()) {
|
||||
printf("%s\n", stream.error.c_str());
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
#ifdef TINT_ENABLE_MSL_COMPILATION_USING_METAL_API
|
||||
if (req.language == SourceLanguage::MSL) {
|
||||
|
@ -385,13 +388,14 @@ bool RunServer(std::string port) {
|
|||
resp.error = result.output;
|
||||
}
|
||||
stream << resp;
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
CompileResponse resp;
|
||||
resp.error = "server cannot compile this type of shader";
|
||||
stream << resp;
|
||||
}
|
||||
}).detach();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue