Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --ponyhelp option to compiled program #3312

Merged
merged 2 commits into from
Sep 28, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 1 addition & 32 deletions src/libponyc/options/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,38 +190,7 @@ static void usage(void)
" --antlr Print out the Pony grammar as an ANTLR file.\n"
" --lint-llvm Run the LLVM linting pass on generated IR.\n"
,
"Runtime options for Pony programs (not for use with ponyc):\n"
" --ponythreads Use N scheduler threads. Defaults to the number of\n"
" cores (not hyperthreads) available.\n"
" This can't be larger than the number of cores available.\n"
" --ponyminthreads Minimum number of active scheduler threads allowed.\n"
" Defaults to 0, meaning that all scheduler threads are\n"
" allowed to be suspended when no work is available.\n"
" This can't be larger than --ponythreads if provided,\n"
" or the physical cores available\n"
" --ponynoscale Don't scale down the scheduler threads.\n"
" See --ponythreads on how to specify the number of threads\n"
" explicitly. Can't be used with --ponyminthreads.\n"
" --ponysuspendthreshold\n"
" Amount of idle time before a scheduler thread suspends\n"
" itself to minimize resource consumption (max 1000 ms,\n"
" min 1 ms).\n"
" Defaults to 1 ms.\n"
" --ponycdinterval Run cycle detection every N ms (max 1000 ms, min 10 ms).\n"
" Defaults to 100 ms.\n"
" --ponygcinitial Defer garbage collection until an actor is using at\n"
" least 2^N bytes. Defaults to 2^14.\n"
" --ponygcfactor After GC, an actor will next be GC'd at a heap memory\n"
" usage N times its current value. This is a floating\n"
" point value. Defaults to 2.0.\n"
" --ponynoyield Do not yield the CPU when no work is available.\n"
" --ponynoblock Do not send block messages to the cycle detector.\n"
" --ponypin Pin scheduler threads to CPU cores. The ASIO thread\n"
" can also be pinned if `--ponypinasio` is set.\n"
" --ponypinasio Pin the ASIO thread to a CPU the way scheduler\n"
" threads are pinned to CPUs. Requires `--ponypin` to\n"
" be set to have any effect.\n"
" --ponyversion Print the version of the compiler and exit.\n"
PONYRT_HELP
);
}

Expand Down
34 changes: 34 additions & 0 deletions src/libponyrt/options/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,40 @@
#define OPT_ARG_OPTIONAL 1 << 1
#define OPT_ARG_NONE 1 << 2
#define OPT_ARGS_FINISH {NULL, 0, UINT32_MAX, UINT32_MAX}
#define PONYRT_HELP \
"Runtime options for Pony programs (not for use with ponyc):\n" \
" --ponythreads Use N scheduler threads. Defaults to the number of\n" \
" cores (not hyperthreads) available.\n" \
" This can't be larger than the number of cores available.\n" \
" --ponyminthreads Minimum number of active scheduler threads allowed.\n" \
" Defaults to 0, meaning that all scheduler threads are\n" \
" allowed to be suspended when no work is available.\n" \
" This can't be larger than --ponythreads if provided,\n" \
" or the physical cores available\n" \
" --ponynoscale Don't scale down the scheduler threads.\n" \
" See --ponythreads on how to specify the number of threads\n" \
" explicitly. Can't be used with --ponyminthreads.\n" \
" --ponysuspendthreshold\n" \
" Amount of idle time before a scheduler thread suspends\n" \
" itself to minimize resource consumption (max 1000 ms,\n" \
" min 1 ms).\n" \
" Defaults to 1 ms.\n" \
" --ponycdinterval Run cycle detection every N ms (max 1000 ms, min 10 ms).\n" \
" Defaults to 100 ms.\n" \
" --ponygcinitial Defer garbage collection until an actor is using at\n" \
" least 2^N bytes. Defaults to 2^14.\n" \
" --ponygcfactor After GC, an actor will next be GC'd at a heap memory\n" \
" usage N times its current value. This is a floating\n" \
" point value. Defaults to 2.0.\n" \
" --ponynoyield Do not yield the CPU when no work is available.\n" \
" --ponynoblock Do not send block messages to the cycle detector.\n" \
" --ponypin Pin scheduler threads to CPU cores. The ASIO thread\n" \
" can also be pinned if `--ponypinasio` is set.\n" \
" --ponypinasio Pin the ASIO thread to a CPU the way scheduler\n" \
" threads are pinned to CPUs. Requires `--ponypin` to\n" \
" be set to have any effect.\n" \
" --ponyversion Print the version of the compiler and exit.\n" \
" --ponyhelp Print the runtime usage options and exit.\n"

typedef struct opt_arg_t
{
Expand Down
11 changes: 10 additions & 1 deletion src/libponyrt/sched/start.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ typedef struct options_t
bool nopin;
bool pinasio;
bool version;
bool ponyhelp;
} options_t;

typedef enum running_kind_t
Expand Down Expand Up @@ -63,7 +64,8 @@ enum
OPT_NOBLOCK,
OPT_PIN,
OPT_PINASIO,
OPT_VERSION
OPT_VERSION,
OPT_PONYHELP
};

static opt_arg_t args[] =
Expand All @@ -80,6 +82,7 @@ static opt_arg_t args[] =
{"ponypin", 0, OPT_ARG_NONE, OPT_PIN},
{"ponypinasio", 0, OPT_ARG_NONE, OPT_PINASIO},
{"ponyversion", 0, OPT_ARG_NONE, OPT_VERSION},
{"ponyhelp", 0, OPT_ARG_NONE, OPT_PONYHELP},

OPT_ARGS_FINISH
};
Expand Down Expand Up @@ -107,6 +110,7 @@ static int parse_opts(int argc, char** argv, options_t* opt)
case OPT_PIN: opt->nopin = false; break;
case OPT_PINASIO: opt->pinasio = true; break;
case OPT_VERSION: opt->version = true; break;
case OPT_PONYHELP: opt->ponyhelp = true; break;

default: exit(-1);
}
Expand Down Expand Up @@ -154,6 +158,11 @@ PONY_API int pony_init(int argc, char** argv)

argc = parse_opts(argc, argv, &opt);

if (opt.ponyhelp) {
printf("%s", PONYRT_HELP);
exit(0);
}

if (opt.version) {
#ifdef _MSC_VER
printf("%s %d\n", PONY_VERSION_STR, _MSC_VER);
Expand Down