From: Woongsuk Cho Date: Mon, 18 Nov 2024 22:55:52 +0000 (+0900) Subject: Add --parallelism option for crossgen2 X-Git-Tag: accepted/tizen/9.0/unified/20241121.045854~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b7ce7a5d1b8dd04661f0bda98c311cc4c8b0baea;p=platform%2Fcore%2Fdotnet%2Flauncher.git Add --parallelism option for crossgen2 To control thread number of crossgen2, add --parallelism option the default value is logical cpu number and it should be bigger than 1 --- diff --git a/NativeLauncher/inc/ni_common.h b/NativeLauncher/inc/ni_common.h index 1fdbf33..7189b34 100644 --- a/NativeLauncher/inc/ni_common.h +++ b/NativeLauncher/inc/ni_common.h @@ -41,6 +41,7 @@ #define NI_FLAGS_SKIP_RO_APP 0x0400 #define NI_FLAGS_RM_ORIGIN_AFTER_NI 0x0800 #define NI_FLAGS_SET_PRIORITY 0x1000 +#define NI_FLAGS_PARALLELISM 0x2000 typedef std::function afterCreate; @@ -63,6 +64,7 @@ typedef struct NIOption{ std::vector inputBubbleRefFiles; std::vector mibcPath; int priority; + std::string threadNum; } NIOption; /** diff --git a/NativeLauncher/tool/dotnettool.cc b/NativeLauncher/tool/dotnettool.cc index d65454a..baaa2ec 100644 --- a/NativeLauncher/tool/dotnettool.cc +++ b/NativeLauncher/tool/dotnettool.cc @@ -80,6 +80,7 @@ void DisplayUsage() { " Note!: App ATOC options(--ni-pkg, --ni-regen-all-app, --tac-regen-all) cannot be used with --rm-origin-after-ni option.\n" " (Use only for assemblies that will not be AOTed again afterward.)\n" " --set-priority - Sets the priority of the process to the specified values from -20(highest priority) to 19(lowest priority).(default : 0)\n" + " --parallelism - Sets the maximum number of threads to use in AOTC (default = logical processor count)\n" "\n" "Usage: dotnettool [options] [command] [arguments]\n" @@ -399,6 +400,27 @@ int main(int argc, char* argv[]) DisplayUsage(); return -1; } + } else if (arg == "--parallelism") { + ++i; + if (i >= argc) { + _SOUT("Number of threads (minimum 1) should be followed for --parallelism option"); + DisplayUsage(); + return -1; + } + + opt->flags |= NI_FLAGS_PARALLELISM; + try { + opt->threadNum = argv[i]; + if (std::stoi(argv[i]) < 1) { + _SERR("Number of threads should be bigger than 1 (input : %s)", argv[i]); + DisplayUsage(); + return -1; + } + } catch (...) { + _SERR("Invalid argument: %s", argv[i]); + DisplayUsage(); + return -1; + } } else if (arg == "--mibc") { ++i; if (i >= argc) { diff --git a/NativeLauncher/tool/ni_common.cc b/NativeLauncher/tool/ni_common.cc index f5a00da..5deb65b 100644 --- a/NativeLauncher/tool/ni_common.cc +++ b/NativeLauncher/tool/ni_common.cc @@ -73,8 +73,7 @@ static const char* CROSSGEN_OPT_JITPATH = "--jitpath"; static const char* CROSSGEN_OPT_TARGET_ARCH = "--targetarch"; static const char* CROSSGEN_OPT_OUT_NEAR_INPUT = "--out-near-input"; static const char* CROSSGEN_OPT_SINGLE_FILE_COMPILATION = "--single-file-compilation"; -//static const char* CROSSGEN_OPT_PARALLELISM = "--parallelism"; -//static const char* CROSSGEN_OPT_PARALLELISM_COUNT = "5"; +static const char* CROSSGEN_OPT_PARALLELISM = "--parallelism"; static const char* CROSSGEN_OPT_RESILIENT = "--resilient"; //static const char* CROSSGEN_OPT_OPTIMIZE = "-O"; static const char* CROSSGEN_OPT_OPTIMIZE_TIME = "--Ot"; @@ -341,8 +340,10 @@ static void makeArgs(std::vector& args, const std::vectorflags & NI_FLAGS_PARALLELISM) { + args.push_back(CROSSGEN_OPT_PARALLELISM); + args.push_back(opt->threadNum.c_str()); + } args.push_back(CROSSGEN_OPT_RESILIENT); args.push_back(CROSSGEN_OPT_OPTIMIZE_TIME);