forked from open-mpi/ompi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request open-mpi#6771 from ggouaillardet/topic/pmix_refresh
pmix/pmix4x: refresh to the latest PMIx master
- Loading branch information
Showing
10 changed files
with
295 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
@PMIX_PYTHON_PATH@ | ||
|
||
from pmix import * | ||
import signal, time | ||
import os | ||
import select | ||
import subprocess | ||
|
||
global killer | ||
|
||
class GracefulKiller: | ||
kill_now = False | ||
def __init__(self): | ||
signal.signal(signal.SIGINT, self.exit_gracefully) | ||
signal.signal(signal.SIGTERM, self.exit_gracefully) | ||
|
||
def exit_gracefully(self,signum, frame): | ||
self.kill_now = True | ||
|
||
def clientconnected(proc:tuple is not None): | ||
print("CLIENT CONNECTED", proc) | ||
return PMIX_SUCCESS | ||
|
||
def clientfinalized(proc:tuple is not None): | ||
print("CLIENT FINALIZED", proc) | ||
return PMIX_SUCCESS | ||
|
||
def clientfence(args:dict is not None): | ||
print("SERVER FENCE", args) | ||
return PMIX_SUCCESS | ||
|
||
def main(): | ||
try: | ||
foo = PMIxServer() | ||
except: | ||
print("FAILED TO CREATE SERVER") | ||
exit(1) | ||
print("Testing server version ", foo.get_version()) | ||
args = {PMIX_SERVER_SCHEDULER: ('T', PMIX_BOOL)} | ||
map = {'clientconnected': clientconnected, | ||
'clientfinalized': clientfinalized, | ||
'fencenb': clientfence} | ||
my_result = foo.init(args, map) | ||
print("Testing PMIx_Initialized") | ||
rc = foo.initialized() | ||
print("Initialized: ", rc) | ||
vers = foo.get_version() | ||
print("Version: ", vers) | ||
|
||
# Register a fabric | ||
rc = foo.register_fabric(None) | ||
print("Fabric registered: ", rc) | ||
|
||
# Get the number of vertices in this fabric | ||
nverts = foo.get_num_vertices() | ||
print("Nverts in fabric: ", nverts) | ||
|
||
# setup the application | ||
(rc, regex) = foo.generate_regex("test000,test001,test002") | ||
print("Node regex: ", regex) | ||
(rc, ppn) = foo.generate_ppn("0,1,2;3,4,5;6,7") | ||
print("PPN: ", ppn) | ||
darray = (PMIX_INFO, [{PMIX_ALLOC_NETWORK_ID: ("SIMPSCHED.net", PMIX_STRING)}, | ||
{PMIX_ALLOC_NETWORK_SEC_KEY: ('T', PMIX_BOOL)}, | ||
{PMIX_SETUP_APP_ENVARS: ('T', PMIX_BOOL)}]) | ||
kyvals = {PMIX_NODE_MAP: (regex, PMIX_STRING), PMIX_PROC_MAP: (ppn, PMIX_STRING), PMIX_ALLOC_NETWORK: (darray, PMIX_DATA_ARRAY)} | ||
|
||
appinfo = [] | ||
rc, appinfo = foo.setup_application("SIMPSCHED", kyvals) | ||
print("SETUPAPP: ", appinfo) | ||
|
||
rc = foo.setup_local_support("SIMPSCHED", appinfo) | ||
print("SETUPLOCAL: ", rc) | ||
|
||
# get our environment as a base | ||
env = os.environ.copy() | ||
|
||
# register an nspace for the client app | ||
kvals = {PMIX_NODE_MAP: (regex, PMIX_STRING), PMIX_PROC_MAP: (ppn, PMIX_STRING), PMIX_UNIV_SIZE: (1, PMIX_UINT32), PMIX_JOB_SIZE: (1, PMIX_UINT32)} | ||
print("REGISTERING NSPACE") | ||
rc = foo.register_nspace("testnspace", 1, kvals) | ||
print("RegNspace ", rc) | ||
|
||
# register a client | ||
uid = os.getuid() | ||
gid = os.getgid() | ||
print("REGISTERING CLIENT") | ||
rc = foo.register_client(("testnspace", 0), uid, gid) | ||
print("RegClient ", rc) | ||
|
||
# setup the fork | ||
rc = foo.setup_fork(("testnspace", 0), env) | ||
print("SetupFrk", rc) | ||
|
||
# setup the client argv | ||
args = ["./client.py"] | ||
# open a subprocess with stdout and stderr | ||
# as distinct pipes so we can capture their | ||
# output as the process runs | ||
p = subprocess.Popen(args, env=env, | ||
stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||
# define storage to catch the output | ||
stdout = [] | ||
stderr = [] | ||
# loop until the pipes close | ||
while True: | ||
reads = [p.stdout.fileno(), p.stderr.fileno()] | ||
ret = select.select(reads, [], []) | ||
|
||
stdout_done = True | ||
stderr_done = True | ||
|
||
for fd in ret[0]: | ||
# if the data | ||
if fd == p.stdout.fileno(): | ||
read = p.stdout.readline() | ||
if read: | ||
read = read.decode('utf-8').rstrip() | ||
print('stdout: ' + read) | ||
stdout_done = False | ||
elif fd == p.stderr.fileno(): | ||
read = p.stderr.readline() | ||
if read: | ||
read = read.decode('utf-8').rstrip() | ||
print('stderr: ' + read) | ||
stderr_done = False | ||
|
||
if stdout_done and stderr_done: | ||
break | ||
|
||
print("FINALIZING") | ||
foo.finalize() | ||
|
||
if __name__ == '__main__': | ||
global killer | ||
killer = GracefulKiller() | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.