SPANK

Section: Slurm Component (8)
Updated: Slurm Component
Index

 

NAME

SPANK - Slurm Plug-in Architecture for Node and job (K)control
SPANK-ノードおよびジョブ(K)制御用のSlurmプラグインアーキテクチャ

 

DESCRIPTION

This manual briefly describes the capabilities of the Slurm Plug-in architecture for Node and job Kontrol (SPANK) as well as the SPANK configuration file: (By default: plugstack.conf.)
このマニュアルでは、ノードおよびジョブ制御(SPANK)のSlurmプラグインアーキテクチャーの機能と、SPANK構成ファイル(デフォルト:plugstack.conf)について簡単に説明します。

SPANK provides a very generic interface for stackable plug-ins which may be used to dynamically modify the job launch code in Slurm.
SPANKは、Slurmのジョブ起動コードを動的に変更するために使用できるスタック可能なプラグイン用の非常に汎用的なインターフェースを提供します。
SPANK plugins may be built without access to Slurm source code.
SPANKプラグインは、Slurmソースコードにアクセスせずにビルドされる場合があります。
They need only be compiled against Slurm's spank.h header file, added to the SPANK config file plugstack.conf, and they will be loaded at runtime during the next job launch.
これらは、Slurmのspank.hヘッダーファイルに対してコンパイルし、SPANK構成ファイルplugstack.confに追加するだけでよく、実行時に次のジョブの起動時にロードされます。
Thus, the SPANK infrastructure provides administrators and other developers a low cost, low effort ability to dynamically modify the runtime behavior of Slurm job launch.
したがって、SPANKインフラストラクチャは、管理者や他の開発者に、Slurmジョブ起動の実行時の動作を動的に変更するための低コストで低労力の機能を提供します。

Note: SPANK plugins using the Slurm APIs need to be recompiled when upgrading Slurm to a new major release.
注:Slurmを新しいメジャーリリースにアップグレードするときは、SlurmAPIを使用するSPANKプラグインを再コンパイルする必要があります。

 

SPANK PLUGINS

SPANK plugins are loaded in up to five separate contexts during a Slurm job.
SPANKプラグインは、Slurmジョブ中に最大5つの個別のコンテキストにロードされます。
Briefly, the five contexts are:
簡単に言うと、5つのコンテキストは次のとおりです。
local
In local context, the plugin is loaded by srun.
ローカルコンテキストでは、プラグインはsrunによってロードされます。
(i.e. the "local" part of a parallel job).
(つまり、並列ジョブの「ローカル」部分)。
remote
In remote context, the plugin is loaded by slurmstepd.
リモートコンテキストでは、プラグインはslurmstepdによってロードされます。
(i.e. the "remote" part of a parallel job).
(つまり、並列ジョブの「リモート」部分)。
allocator
In allocator context, the plugin is loaded in one of the job allocation utilities sbatch or salloc.
アロケータコンテキストでは、プラグインはジョブ割り当てユーティリティsbatchまたはsallocのいずれかにロードされます。

slurmd In slurmd context, the plugin is loaded in the
slurmd daemon itself.
slurmd slurmdコンテキストでは、プラグインはslurmdデーモン自体にロードされます。
Note: Plugins loaded in slurmd context persist for the entire time slurmd is running, so if configuration is changed or plugins are updated, slurmd must be restarted for the changes to take effect.
注:slurmdコンテキストにロードされたプラグインは、slurmdが実行されている間ずっと存続するため、構成が変更されたりプラグインが更新されたりした場合、変更を有効にするにはslurmdを再起動する必要があります。

job_script
In the job_script context, plugins are loaded in the context of the job prolog or epilog.
job_scriptコンテキストでは、プラグインはジョブプロローグまたはエピローグのコンテキストでロードされます。
Note: Plugins are loaded in job_script context on each run on the job prolog or epilog, in a separate address space from plugins in slurmd context.
注:プラグインは、slurmdコンテキストのプラグインとは別のアドレス空間で、ジョブのプロローグまたはエピローグで実行されるたびにjob_scriptコンテキストにロードされます。
This means there is no state shared between this context and other contexts, or even between one call to slurm_spank_job_prolog or slurm_spank_job_epilog and subsequent calls.
これは、このコンテキストと他のコンテキストの間、またはslurm_spank_job_prologまたはslurm_spank_job_epilogへの1回の呼び出しとその後の呼び出しの間でさえ共有される状態がないことを意味します。

In local context, only the init, exit, init_post_opt, and local_user_init functions are called.
ローカルコンテキストでは、init、exit、init_post_opt、およびlocal_user_init関数のみが呼び出されます。
In allocator context, only the init, exit, and init_post_opt functions are called.
アロケータコンテキストでは、init、exit、およびinit_post_opt関数のみが呼び出されます。
Similarly, in slurmd context, only the init and slurmd_exit callbacks are active, and in the job_script context, only the job_prolog and job_epilog callbacks are used.
同様に、slurmdコンテキストでは、initおよびslurmd_exitコールバックのみがアクティブであり、job_scriptコンテキストでは、job_prologおよびjob_epilogコールバックのみが使用されます。
Plugins may query the context in which they are running with the spank_context and spank_remote functions defined in <slurm/spank.h>.
プラグインは、<slurm / spank.h>で定義されているspank_context関数とspank_remote関数を使用して、実行中のコンテキストを照会できます。

SPANK plugins may be called from multiple points during the Slurm job launch.
SPANKプラグインは、Slurmジョブの起動中に複数のポイントから呼び出される場合があります。
A plugin may define the following functions:
プラグインは次の関数を定義する場合があります。

slurm_spank_init
Called just after plugins are loaded.
プラグインがロードされた直後に呼び出されます。
In remote context, this is just after job step is initialized.
リモートコンテキストでは、これはジョブステップが初期化された直後です。
This function is called before any plugin option processing.
この関数は、プラグインオプションが処理される前に呼び出されます。
slurm_spank_job_prolog
Called at the same time as the job prolog.
ジョブプロローグと同時に呼び出されます。
If this function returns a negative value and the SPANK plugin that contains it is required in the plugstack.conf, the node that this is run on will be drained.
この関数が負の値を返し、それを含むSPANKプラグインがplugstack.confで必要な場合、これが実行されているノードはドレインされます。

slurm_spank_init_post_opt
Called at the same point as slurm_spank_init, but after all user options to the plugin have been processed.
slurm_spank_initと同じポイントで呼び出されますが、プラグインに対するすべてのユーザーオプションが処理された後です。
The reason that the init and init_post_opt callbacks are separated is so that plugins can process system-wide options specified in plugstack.conf in the init callback, then process user options, and finally take some action in slurm_spank_init_post_opt if necessary.
initコールバックとinit_post_optコールバックが分離されている理由は、プラグインがinitコールバックのplugstack.confで指定されたシステム全体のオプションを処理し、次にユーザーオプションを処理し、最後に必要に応じてslurm_spank_init_post_optで何らかのアクションを実行できるようにするためです。
In the case of a heterogeneous job, slurm_spank_init is invoked once per job component.
異種ジョブの場合、slurm_spank_initはジョブコンポーネントごとに1回呼び出されます。
slurm_spank_local_user_init
Called in local (srun) context only after all options have been processed.
すべてのオプションが処理された後にのみ、ローカル(srun)コンテキストで呼び出されます。
This is called after the job ID and step IDs are available.
これは、ジョブIDとステップIDが使用可能になった後に呼び出されます。
This happens in srun after the allocation is made, but before tasks are launched.
これは、割り当てが行われた後、タスクが起動される前にsrunで発生します。
slurm_spank_user_init
Called after privileges are temporarily dropped.
特権が一時的に削除された後に呼び出されます。
(remote context only)
(リモートコンテキストのみ)
slurm_spank_task_init_privileged
Called for each task just after fork, but before all elevated privileges are dropped.
フォークの直後、ただしすべての昇格された特権が削除される前に、タスクごとに呼び出されます。
(remote context only)
(リモートコンテキストのみ)
slurm_spank_task_init
Called for each task just before execve (2).
execve(2)の直前に各タスクに対して呼び出されます。
If you are restricing memory with cgroups, memory allocated here will be in the job's cgroup.
cgroupを使用してメモリを制限している場合、ここで割り当てられたメモリはジョブのcgroupにあります。
(remote context only)
(リモートコンテキストのみ)
slurm_spank_task_post_fork
Called for each task from parent process after fork (2) is complete.
fork(2)が完了した後、親プロセスから各タスクに対して呼び出されます。
Due to the fact that slurmd does not exec any tasks until all tasks have completed fork (2), this call is guaranteed to run before the user task is executed.
slurmdはすべてのタスクがfork(2)を完了するまでタスクを実行しないため、この呼び出しはユーザータスクが実行される前に実行されることが保証されています。
(remote context only)
(リモートコンテキストのみ)
slurm_spank_task_exit
Called for each task as its exit status is collected by Slurm.
終了ステータスがSlurmによって収集されるため、タスクごとに呼び出されます。
(remote context only)
slurm_spank_exit
Called once just before slurmstepd exits in remote context.
リモートコンテキストでslurmstepdが終了する直前に1回呼び出されます。
In local context, called before srun exits.
ローカルコンテキストでは、srunが終了する前に呼び出されます。
slurm_spank_job_epilog
Called at the same time as the job epilog.
ジョブエピローグと同時に呼び出されます。
If this function returns a negative value and the SPANK plugin that contains it is required in the plugstack.conf, the node that this is run on will be drained.
この関数が負の値を返し、それを含むSPANKプラグインがplugstack.confで必要な場合、これが実行されているノードはドレインされます。
slurm_spank_slurmd_exit
Called in slurmd when the daemon is shut down.
デーモンがシャットダウンされたときにslurmdで呼び出されます。

All of these functions have the same prototype, for example:
これらの関数はすべて同じプロトタイプを持っています。次に例を示します。


   int slurm_spank_init (spank_t spank, int ac, char *argv[])

Where spank is the SPANK handle which must be passed back to Slurm when the plugin calls functions like spank_get_item and spank_getenv.
ここで、spankはSPANKハンドルであり、プラグインがspank_get_itemやspank_getenvなどの関数を呼び出すときにSlurmに戻す必要があります。
Configured arguments (See CONFIGURATION below) are passed in the argument vector argv with argument count ac.
構成された引数(以下の構成を参照)は、引数数acで引数ベクトルargvに渡されます。

SPANK plugins can query the current list of supported slurm_spank symbols to determine if the current version supports a given plugin hook.
SPANKプラグインは、サポートされているslurm_spankシンボルの現在のリストを照会して、現在のバージョンが特定のプラグインフックをサポートしているかどうかを判断できます。
This may be useful because the list of plugin symbols may grow in the future.
プラグインシンボルのリストは将来増える可能性があるため、これは便利な場合があります。
The query is done using the spank_symbol_supported function, which has the following prototype:
クエリは、次のプロトタイプを持つspank_symbol_supported関数を使用して実行されます。


    int spank_symbol_supported (const char *sym);

The return value is 1 if the symbol is supported, 0 if not.
戻り値は、シンボルがサポートされている場合は1、サポートされていない場合は0です。

SPANK plugins do not have direct access to internally defined Slurm data structures.
SPANKプラグインは、内部で定義されたSlurmデータ構造に直接アクセスできません。
Instead, information about the currently executing job is obtained via the spank_get_item function call.
代わりに、現在実行中のジョブに関する情報は、spank_get_item関数呼び出しを介して取得されます。


  spank_err_t spank_get_item (spank_t spank, spank_item_t item, ...);

The spank_get_item call must be passed the current SPANK handle as well as the item requested, which is defined by the passed spank_item_t.
spank_get_item呼び出しには、現在のSPANKハンドルと、渡されたspank_item_tによって定義された要求されたアイテムを渡す必要があります。
A variable number of pointer arguments are also passed, depending on which item was requested by the plugin.
プラグインによって要求されたアイテムに応じて、可変数のポインタ引数も渡されます。
A list of the valid values for item is kept in the spank.h header file.
itemの有効な値のリストは、spank.hヘッダーファイルに保持されます。
Some examples are:
いくつかの例は次のとおりです。
S_JOB_UID
User id for running job.
ジョブを実行するためのユーザーID。
(uid_t *) is third arg of spank_get_item
(uid_t *)はspank_get_itemの3番目の引数です
S_JOB_STEPID
Job step id for running job.
ジョブを実行するためのジョブステップID。
(uint32_t *) is third arg of spank_get_item.
(uint32_t *)は、spank_get_itemの3番目の引数です。
S_TASK_EXIT_STATUS
Exit status for exited task.
終了したタスクの終了ステータス。
Only valid from slurm_spank_task_exit.
slurm_spank_task_exitからのみ有効です。
(int *) is third arg of spank_get_item.
S_JOB_ARGV
Complete job command line.
完全なジョブコマンドライン。
Third and fourth args to spank_get_item are (int *, char ***).
spank_get_itemの3番目と4番目の引数は(int *、char ***)です。

See spank.h for more details, and EXAMPLES below for an example of spank_get_item usage.
詳細についてはspank.hを、spank_get_itemの使用例については以下の例を参照してください。

SPANK functions in the local and allocator environment should use the getenv, setenv, and unsetenv functions to view and modify the job's environment.
ローカルおよびアロケーター環境のSPANK関数は、getenv、setenv、およびunsetenv関数を使用して、ジョブの環境を表示および変更する必要があります。
SPANK functions in the remote environment should use the spank_getenv, spank_setenv, and spank_unsetenv functions to view and modify the job's environment.
リモート環境のSPANK関数は、spank_getenv、spank_setenv、およびspank_unsetenv関数を使用して、ジョブの環境を表示および変更する必要があります。
spank_getenv searches the job's environment for the environment variable var and copies the current value into a buffer buf of length len.
spank_getenvは、ジョブの環境で環境変数varを検索し、現在の値を長さlenのバッファーbufにコピーします。
spank_setenv allows a SPANK plugin to set or overwrite a variable in the job's environment, and spank_unsetenv unsets an environment variable in the job's environment.
spank_setenvを使用すると、SPANKプラグインでジョブの環境内の変数を設定または上書きでき、spank_unsetenvを使用すると、ジョブの環境内の環境変数の設定を解除できます。
The prototypes are:
プロトタイプは次のとおりです。


 spank_err_t spank_getenv (spank_t spank, const char *var,
                           char *buf, int len);
 spank_err_t spank_setenv (spank_t spank, const char *var,
                           const char *val, int overwrite);
 spank_err_t spank_unsetenv (spank_t spank, const char *var);

These are only necessary in remote context since modifications of the standard process environment using setenv (3), getenv (3), and unsetenv (3) may be used in local context.
setenv(3)、getenv(3)、およびunsetenv(3)を使用した標準プロセス環境の変更はローカルコンテキストで使用される可能性があるため、これらはリモートコンテキストでのみ必要です。

Functions are also available from within the SPANK plugins to establish environment variables to be exported to the Slurm PrologSlurmctld, Prolog, Epilog and EpilogSlurmctld programs (the so-called job control environment).
SPANKプラグイン内から関数を使用して、Slurm PrologSlurmctld、Prolog、Epilog、およびEpilogSlurmctldプログラム(いわゆるジョブ制御環境)にエクスポートする環境変数を確立することもできます。
The name of environment variables established by these calls will be prepended with the string SPANK_ in order to avoid any security implications of arbitrary environment variable control.
これらの呼び出しによって確立された環境変数の名前には、任意の環境変数制御によるセキュリティへの影響を回避するために、文字列SPANK_が付加されます。
(After all, the job control scripts do run as root or the Slurm user.).
(結局のところ、ジョブ制御スクリプトはrootまたはSlurmユーザーとして実行されます。)

These functions are available from local context only.
これらの関数は、ローカルコンテキストからのみ使用できます。


  spank_err_t spank_job_control_getenv(spank_t spank, const char *var,
                             char *buf, int len);
  spank_err_t spank_job_control_setenv(spank_t spank, const char *var,
                             const char *val, int overwrite);
  spank_err_t spank_job_control_unsetenv(spank_t spank, const char *var);

See spank.h for more information, and EXAMPLES below for an example for spank_getenv usage.
詳細についてはspank.hを、spank_getenvの使用例については以下の例を参照してください。

Many of the described SPANK functions available to plugins return errors via the spank_err_t error type.
プラグインで使用できる説明されているSPANK関数の多くは、spank_err_tエラータイプを介してエラーを返します。
On success, the return value will be set to ESPANK_SUCCESS, while on failure, the return value will be set to one of many error values defined in slurm/spank.h.
成功すると、戻り値はESPANK_SUCCESSに設定され、失敗すると、戻り値はslurm /spank.hで定義されている多くのエラー値の1つに設定されます。
The SPANK interface provides a simple function
SPANKインターフェースはシンプルな機能を提供します


  const char * spank_strerror(spank_err_t err);

which may be used to translate a spank_err_t value into its string representation.
これは、spank_err_t値をその文字列表現に変換するために使用できます。

The slurm_spank_log function can be used to print messages back to the user at an error level.
slurm_spank_log関数を使用して、エラーレベルでユーザーにメッセージを出力することができます。
This is to keep users from having to rely on the slurm_error function, which can be confusing because it prepends "error:" to every message.
これは、ユーザーがslurm_error関数に依存する必要がないようにするためです。この関数は、すべてのメッセージの前に「error:」を付けるため、混乱する可能性があります。

 

SPANK OPTIONS

SPANK plugins also have an interface through which they may define and implement extra job options.
SPANKプラグインには、追加のジョブオプションを定義および実装するためのインターフェイスもあります。
These options are made available to the user through Slurm commands such as srun(1), salloc(1), and sbatch(1).
これらのオプションは、srun(1)、salloc(1)、sbatch(1)などのSlurmコマンドを介してユーザーが利用できるようになります。
If the option is specified by the user, its value is forwarded and registered with the plugin in slurmd when the job is run.
オプションがユーザーによって指定された場合、その値はジョブの実行時に転送され、slurmdのプラグインに登録されます。
In this way, SPANK plugins may dynamically provide new options and functionality to Slurm.
このように、SPANKプラグインはSlurmに新しいオプションと機能を動的に提供する場合があります。

Each option registered by a plugin to Slurm takes the form of a struct spank_option which is declared in <slurm/spank.h> as
プラグインによってSlurmに登録された各オプションは、<slurm /spank.h>で次のように宣言されたstructspank_optionの形式を取ります。


   struct spank_option {
      char *         name;
      char *         arginfo;
      char *         usage;
      int            has_arg;
      int            val;
      spank_opt_cb_f cb;
   };

Where

name
is the name of the option.
オプションの名前です。
Its length is limited to SPANK_OPTION_MAXLEN defined in <slurm/spank.h>.
その長さは、<slurm /spank.h>で定義されているSPANK_OPTION_MAXLENに制限されています。
arginfo
is a description of the argument to the option, if the option does take an argument.
オプションが引数を取る場合は、オプションの引数の説明です。
usage
is a short description of the option suitable for --help output.
--help出力に適したオプションの簡単な説明です。
has_arg
0 if option takes no argument, 1 if option takes an argument, and 2 if the option takes an optional argument.
オプションが引数をとらない場合は0、オプションが引数をとる場合は1、オプションがオプションの引数をとる場合は2。
(See getopt_long (3)).
(getopt_long(3)を参照)。
val
A plugin-local value to return to the option callback function.
オプションのコールバック関数に戻るプラグインローカル値。
cb
A callback function that is invoked when the plugin option is registered with Slurm.
プラグインオプションがSlurmに登録されたときに呼び出されるコールバック関数。
spank_opt_cb_f is typedef'd in <slurm/spank.h> as
spank_opt_cb_fは、<slurm /spank.h>で次のようにtypedefされます。

  typedef int (*spank_opt_cb_f) (int val, const char *optarg,
                                 int remote);

Where val is the value of the val field in the spank_option struct, optarg is the supplied argument if applicable, and remote is 0 if the function is being called from the "local" host (e.g. host where srun or sbatch/salloc are invoked) or 1 from the "remote" host (host where slurmd/slurmstepd run) but only executed by slurmstepd (remote context) if the option was registered for such context.
ここで、valはspank_option構造体のvalフィールドの値であり、optargは該当する場合は指定された引数であり、関数が「ローカル」ホスト(たとえば、srunまたはsbatch / sallocが呼び出されるホスト)から呼び出されている場合はremoteは0です。または「リモート」ホスト(slurmd / slurmstepdが実行されるホスト)から1つですが、オプションがそのようなコンテキストに登録されている場合にのみ、slurmstepd(リモートコンテキスト)によって実行されます。

Plugin options may be registered with Slurm using the spank_option_register function.
プラグインオプションは、spank_option_register関数を使用してSlurmに登録できます。
This function is only valid when called from the plugin's slurm_spank_init handler, and registers one option at a time.
この関数は、プラグインのslurm_spank_initハンドラーから呼び出された場合にのみ有効であり、一度に1つのオプションを登録します。
The prototype is
プロトタイプは


   spank_err_t spank_option_register (spank_t sp,
                   struct spank_option *opt);

This function will return ESPANK_SUCCESS on successful registration of an option, or ESPANK_BAD_ARG for errors including invalid spank_t handle, or when the function is not called from the slurm_spank_init function.
この関数は、オプションの登録が成功した場合、または無効なspank_tハンドルを含むエラーの場合、または関数がslurm_spank_init関数から呼び出されなかった場合に、ESPANK_SUCCESSを返します。
All options need to be registered from all contexts in which they will be used.
すべてのオプションは、それらが使用されるすべてのコンテキストから登録する必要があります。
For instance, if an option is only used in local (srun) and remote (slurmd) contexts, then spank_option_register should only be called from within those contexts.
たとえば、オプションがローカル(srun)およびリモート(slurmd)コンテキストでのみ使用される場合、spank_option_registerはそれらのコンテキスト内からのみ呼び出す必要があります。
For example:
例えば:

   if (spank_context() != S_CTX_ALLOCATOR)
      spank_option_register (sp, opt);

If, however, the option is used in all contexts, the spank_option_register needs to be called everywhere.
ただし、オプションがすべてのコンテキストで使用される場合は、spank_option_registerをどこでも呼び出す必要があります。

In addition to spank_option_register, plugins may also export options to Slurm by defining a table of struct spank_option with the symbol name spank_options.
プラグインは、spank_option_registerに加えて、シンボル名spank_optionsでstruct spank_optionのテーブルを定義することにより、オプションをSlurmにエクスポートすることもできます。
This method, however, is not supported for use with sbatch and salloc (allocator context), thus the use of spank_option_register is preferred.
ただし、このメソッドはsbatchおよびsalloc(アロケーターコンテキスト)での使用はサポートされていないため、spank_option_registerの使用をお勧めします。
When using the spank_options table, the final element in the array must be filled with zeros.
spank_optionsテーブルを使用する場合、配列の最後の要素はゼロで埋める必要があります。
A SPANK_OPTIONS_TABLE_END macro is provided in <slurm/spank.h> for this purpose.
この目的のために、SPANK_OPTIONS_TABLE_ENDマクロが<slurm /spank.h>で提供されています。

When an option is provided by the user on the local side, either by command line options or by environment variables, Slurm will immediately invoke the option's callback with remote=0.
コマンドラインオプションまたは環境変数のいずれかによってローカル側のユーザーがオプションを提供すると、Slurmはすぐにremote = 0でオプションのコールバックを呼び出します。
This is meant for the plugin to do local sanity checking of the option before the value is sent to the remote side during job launch.
これは、ジョブの起動時に値がリモート側に送信される前に、プラグインがオプションのローカル健全性チェックを実行するためのものです。
If the argument the user specified is invalid, the plugin should issue an error and issue a non-zero return code from the callback.
ユーザーが指定した引数が無効な場合、プラグインはエラーを発行し、コールバックからゼロ以外の戻りコードを発行する必要があります。
The plugin should be able to handle cases where the spank option is set multiple times through environment variables and command line options.
プラグインは、spankオプションが環境変数とコマンドラインオプションを介して複数回設定されている場合を処理できる必要があります。
Environment variables are processed before command line options.
環境変数は、コマンドラインオプションの前に処理されます。

On the remote side, options and their arguments are registered just after SPANK plugins are loaded and before the spank_init handler is called.
リモート側では、オプションとその引数は、SPANKプラグインがロードされた直後、spank_initハンドラーが呼び出される前に登録されます。
This allows plugins to modify behavior of all plugin functionality based on the value of user-provided options.
これにより、プラグインは、ユーザー提供のオプションの値に基づいて、すべてのプラグイン機能の動作を変更できます。
(See EXAMPLES below for a plugin that registers an option with Slurm).
(Slurmにオプションを登録するプラグインについては、以下の例を参照してください)。

As an alternative to use of an option callback and global variable, plugins can use the spank_option_getopt option to check for supplied options after option processing.
オプションコールバックとグローバル変数を使用する代わりに、プラグインはspank_option_getoptオプションを使用して、オプション処理後に提供されたオプションをチェックできます。
This function has the prototype:
この関数にはプロトタイプがあります。


   spank_err_t spank_option_getopt(spank_t sp,
       struct spank_option *opt, char **optargp);

This function returns ESPANK_SUCCESS if the option defined in the
struct spank_option opt has been used by the user. If optargp
is non-NULL then it is set to any option argument passed (if the option
takes an argument). The use of this method is required to process
options in job_script context (slurm_spank_job_prolog and
slurm_spank_job_epilog). This function is valid in the following contexts:
slurm_spank_job_prolog, slurm_spank_local_user_init, slurm_spank_user_init,
slurm_spank_task_init_privileged, slurm_spank_task_init, slurm_spank_task_exit,
and slurm_spank_job_epilog.

 

CONFIGURATION

The default SPANK plug-in stack configuration file is plugstack.conf in the same directory as slurm.conf(5), though this may be changed via the Slurm config parameter PlugStackConfig.
デフォルトのSPANKプラグインスタック構成ファイルは、slurm.conf(5)と同じディレクトリにあるplugstack.confですが、これはSlurm構成パラメーターPlugStackConfigを介して変更できます。
Normally the plugstack.conf file should be identical on all nodes of the cluster.
通常、plugstack.confファイルはクラスターのすべてのノードで同一である必要があります。
The config file lists SPANK plugins, one per line, along with whether the plugin is required or optional, and any global arguments that are to be passed to the plugin for runtime configuration.
構成ファイルには、SPANKプラグインが1行に1つずつリストされ、プラグインが必須かオプションか、およびランタイム構成のためにプラグインに渡されるグローバル引数がリストされます。
Comments are preceded with '#' and extend to the end of the line.
コメントの前には「#」が付き、行末まで続きます。
If the configuration file is missing or empty, it will simply be ignored.
構成ファイルが欠落しているか空の場合、それは単に無視されます。

The format of each non-comment line in the configuration file is:
構成ファイルの各非コメント行の形式は次のとおりです。


  required/optional   plugin   arguments

For example:

  optional /usr/lib/slurm/test.so

Tells slurmd to load the plugin test.so passing no arguments.
プラグインtest.soをロードするようにslurmdに指示し、引数を渡しません。
If a SPANK plugin is required, then failure of any of the plugin's functions will cause slurmd to terminate the job, while optional plugins only cause a warning.
SPANKプラグインが必要な場合、プラグインの機能のいずれかに障害が発生すると、slurmdはジョブを終了しますが、オプションのプラグインは警告のみを発生させます。

If a fully-qualified path is not specified for a plugin, then the currently configured PluginDir in slurm.conf(5) is searched.
プラグインに完全修飾パスが指定されていない場合、slurm.conf(5)で現在構成されているPluginDirが検索されます。

SPANK plugins are stackable, meaning that more than one plugin may be placed into the config file.
SPANKプラグインはスタック可能です。つまり、複数のプラグインを構成ファイルに配置できます。
The plugins will simply be called in order, one after the other, and appropriate action taken on failure given that state of the plugin's optional flag.
プラグインは単純に順番に呼び出され、プラグインのオプションフラグの状態を考慮して、失敗した場合に適切なアクションが実行されます。

Additional config files or directories of config files may be included in plugstack.conf with the include keyword.
追加の設定ファイルまたは設定ファイルのディレクトリは、includeキーワードを使用してplugstack.confに含めることができます。
The include keyword must appear on its own line, and takes a glob as its parameter, so multiple files may be included from one include line.
includeキーワードは独自の行に表示する必要があり、パラメーターとしてglobを使用するため、1つのinclude行から複数​​のファイルを含めることができます。
For example, the following syntax will load all config files in the /etc/slurm/plugstack.conf.d directory, in local collation order:
たとえば、次の構文は、/ etc / slurm /plugstack.conf.dディレクトリ内のすべての構成ファイルをローカル照合順序でロードします。


  include /etc/slurm/plugstack.conf.d/*

which might be considered a more flexible method for building up a spank plugin stack.
これは、スパンクプラグインスタックを構築するためのより柔軟な方法と見なされる可能性があります。

The SPANK config file is re-read on each job launch, so editing the config file will not affect running jobs.
SPANK構成ファイルは、ジョブの起動ごとに再読み取りされるため、構成ファイルを編集しても、実行中のジョブには影響しません。
However care should be taken so that a partially edited config file is not read by a launching job.
ただし、部分的に編集された構成ファイルが起動ジョブによって読み取られないように注意する必要があります。

 

EXAMPLES

Simple SPANK config file:


#
# SPANK config file
#
# required?       plugin                     args
#
optional          renice.so                  min_prio=-10
required          /usr/lib/slurm/test.so

The following is a simple SPANK plugin to modify the nice value of job tasks.
以下は、ジョブタスクの優れた値を変更するための単純なSPANKプラグインです。
This plugin adds a --renice=[prio] option to srun which users can use to set the priority of all remote tasks.
このプラグインは、ユーザーがすべてのリモートタスクの優先度を設定するために使用できるsrunに--renice = [prio]オプションを追加します。
Priority may also be specified via a SLURM_RENICE environment variable.
優先度は、SLURM_RENICE環境変数を介して指定することもできます。
A minimum priority may be established via a "min_prio" parameter in plugstack.conf (See above for example).
最小優先度は、plugstack.confの「min_prio」パラメーターを介して確立できます(たとえば、上記を参照)。


/*
 *   To compile:
 *    gcc -shared -o renice.so renice.c
 *
 */
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/resource.h>

#include <slurm/spank.h>

/*
 * All spank plugins must define this macro for the
 * Slurm plugin loader.
 */
SPANK_PLUGIN(renice, 1);

#define PRIO_ENV_VAR "SLURM_RENICE"
#define PRIO_NOT_SET 42

/*
 * Minimum allowable value for priority. May be
 * set globally via plugin option min_prio=<prio>
 */
static int min_prio = -20;

static int prio = PRIO_NOT_SET;

static int _renice_opt_process (int val,
                                const char *optarg,
                                int remote);
static int _str2prio (const char *str, int *p2int);

/*
 *  Provide a --renice=[prio] option to srun:
 */
struct spank_option spank_options[] =
{
    { "renice", "[prio]",
      "Re-nice job tasks to priority [prio].", 2, 0,
      (spank_opt_cb_f) _renice_opt_process
    },
    SPANK_OPTIONS_TABLE_END
};

/*
 *  Called from both srun and slurmd.
 */
int slurm_spank_init (spank_t sp, int ac, char **av)
{
    int i;

    /* Don't do anything in sbatch/salloc */
    if (spank_context () == S_CTX_ALLOCATOR)
        return (0);

    for (i = 0; i < ac; i++) {
        if (strncmp ("min_prio=", av[i], 9) == 0) {
            const char *optarg = av[i] + 9;
            if (_str2prio (optarg, &min_prio) < 0)
                slurm_error ("Ignoring invalid min_prio value: %s",
                             av[i]);
        } else {
            slurm_error ("renice: Invalid option: %s", av[i]);
        }
    }

    if (!spank_remote (sp))
        slurm_verbose ("renice: min_prio = %d", min_prio);

    return (0);
}


int slurm_spank_task_post_fork (spank_t sp, int ac, char **av)
{
    pid_t pid;
    int taskid;

    if (prio == PRIO_NOT_SET) {
        /* See if SLURM_RENICE env var is set by user */
        char val [1024];

        if (spank_getenv (sp, PRIO_ENV_VAR, val, 1024)
            != ESPANK_SUCCESS)
            return (0);

        if (_str2prio (val, &prio) < 0) {
            slurm_error ("Bad value for %s: %s",
                         PRIO_ENV_VAR, optarg);
            return (-1);
        }

        if (prio < min_prio) {
            slurm_error ("%s=%d not allowed, using min=%d",
                         PRIO_ENV_VAR, prio, min_prio);
        }
    }

    if (prio < min_prio)
        prio = min_prio;

    spank_get_item (sp, S_TASK_GLOBAL_ID, &taskid);
    spank_get_item (sp, S_TASK_PID, &pid);

    slurm_info ("re-nicing task%d pid %ld to %ld",
                taskid, pid, prio);

    if (setpriority (PRIO_PROCESS, (int) pid,
                     (int) prio) < 0) {
        slurm_error ("setpriority: %m");
        return (-1);
    }

    return (0);
}

static int _str2prio (const char *str, int *p2int)
{
    long int l;
    char *p;

    l = strtol (str, &p, 10);
    if ((*p != ' ') || (l < -20) || (l > 20))
        return (-1);

    *p2int = (int) l;

    return (0);
}

static int _renice_opt_process (int val,
                                const char *optarg,
                                int remote)
{
    if (optarg == NULL) {
        slurm_error ("renice: invalid argument!");
        return (-1);
    }

    if (_str2prio (optarg, &prio) < 0) {
        slurm_error ("Bad value for --renice: %s",
                     optarg);
        return (-1);
    }

    if (prio < min_prio) {
        slurm_error ("--renice=%d not allowed, will use min=%d",
                     prio, min_prio);
    }

    return (0);
}

 

COPYING

Portions copyright (C) 2010-2018 SchedMD LLC. Copyright (C) 2006 The Regents of the University of California. Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). CODE-OCEC-09-009. All rights reserved.

This file is part of Slurm, a resource management program. For details, see <https://slurm.schedmd.com/>.

Slurm is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Slurm is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.  

FILES

/etc/slurm/slurm.conf - Slurm configuration file.
/etc/slurm/plugstack.conf - SPANK configuration file.
/usr/include/slurm/spank.h - SPANK header file.  

SEE ALSO

srun(1), slurm.conf(5)


 

Index

NAME
DESCRIPTION
SPANK PLUGINS
SPANK OPTIONS
CONFIGURATION
EXAMPLES
COPYING
FILES
SEE ALSO

This document was created by man2html using the manual pages.
Time: 20:44:46 GMT, May 21, 2020