| 431 | } |
| 432 | |
| 433 | bool Compiler::createMultiProcessParser_() { |
| 434 | uint32_t nbProcesses = m_commandLineParser->getNbMaxProcesses(); |
| 435 | if (nbProcesses == 0) return true; |
| 436 | |
| 437 | if (!(m_commandLineParser->writePpOutput() || |
| 438 | m_commandLineParser->writePpOutputFileId())) { |
| 439 | return true; |
| 440 | } |
| 441 | |
| 442 | FileSystem* const fileSystem = FileSystem::getInstance(); |
| 443 | SymbolTable* symbolTable = getSymbolTable(); |
| 444 | |
| 445 | // Create CMakeLists.txt |
| 446 | const bool muted = m_commandLineParser->muteStdout(); |
| 447 | const fs::path outputDir = |
| 448 | fileSystem->toPlatformAbsPath(m_commandLineParser->getOutputDirId()); |
| 449 | const fs::path programPath = |
| 450 | fileSystem->toPlatformAbsPath(m_commandLineParser->getProgramId()); |
| 451 | const std::string_view profile = |
| 452 | m_commandLineParser->profile() ? " -profile " : " "; |
| 453 | const std::string_view sverilog = |
| 454 | m_commandLineParser->fullSVMode() ? " -sverilog " : " "; |
| 455 | const std::string_view fileUnit = |
| 456 | m_commandLineParser->fileunit() ? " -fileunit " : " "; |
| 457 | std::string synth = |
| 458 | m_commandLineParser->reportNonSynthesizable() ? " -synth " : " "; |
| 459 | synth += m_commandLineParser->reportNonSynthesizableWithFormal() ? " -formal " |
| 460 | : " "; |
| 461 | const std::string_view noHash = |
| 462 | m_commandLineParser->noCacheHash() ? " -nohash " : " "; |
| 463 | |
| 464 | // Optimize the load balance, try to even out the work in each thread by |
| 465 | // the size of the files |
| 466 | std::vector<std::vector<CompileSourceFile*>> jobArray(nbProcesses); |
| 467 | std::vector<uint64_t> jobSize(nbProcesses, 0); |
| 468 | size_t largestJob = 0; |
| 469 | for (const auto& compiler : m_compilers) { |
| 470 | size_t size = compiler->getJobSize(CompileSourceFile::Action::Parse); |
| 471 | if (size > largestJob) { |
| 472 | largestJob = size; |
| 473 | } |
| 474 | } |
| 475 | |
| 476 | uint32_t bigJobThreashold = (largestJob / nbProcesses) * 3; |
| 477 | std::vector<CompileSourceFile*> bigJobs; |
| 478 | Precompiled* prec = Precompiled::getSingleton(); |
| 479 | |
| 480 | const fs::path workingDir = fileSystem->getWorkingDir(); |
| 481 | for (const auto& compiler : m_compilers) { |
| 482 | if (prec->isFilePrecompiled(compiler->getFileId(), |
| 483 | compiler->getSymbolTable())) { |
| 484 | continue; |
| 485 | } |
| 486 | uint32_t size = compiler->getJobSize(CompileSourceFile::Action::Parse); |
| 487 | if (size > bigJobThreashold) { |
| 488 | bigJobs.push_back(compiler); |
| 489 | continue; |
| 490 | } |
nothing calls this directly
no test coverage detected