CoCalc Public FilesBoolean-Cayley-graphs / sage-code / save_cast128_in_mpi_parallel.py
Author: Paul Leopardi
Compute Environment: Ubuntu 18.04 (Deprecated)
1r"""
2"""
3#*****************************************************************************
4#       Copyright (C) 2017 Paul Leopardi [email protected]
5#
7#  as published by the Free Software Foundation; either version 2 of
10#*****************************************************************************
11
12import sys
13
14from mpi4py import MPI
15from sage.all_cmdline import *
16
17from boolean_cayley_graphs.classify_in_mpi_parallel import save_class_parts_in_parallel
18
19r"""
20"""
21# Check that the correct number of arguments exist.
22if len(sys.argv) != 4:
23    print("Usage: save_cast128_in_mpi_parallel bnbr fnbr c_len")
24    sys.exit(1)
25
26# Convert the arguments to int.
27bnbr  = int(sys.argv[1]) # S-box number
28fnbr  = int(sys.argv[2]) # Function number within S-box
29c_len = int(sys.argv[3]) # Number of c values per class part.
30
31# Get our MPI rank.
32comm = MPI.COMM_WORLD
33rank = comm.Get_rank()
34
35# Load the required bent function.
38bentf = s_boxes[bnbr][fnbr]
39
40# Save the classification in parts with c_len matrix rows each.
41save_class_parts_in_parallel(
42    comm,
43    "cast128_"+str(bnbr)+"_"+str(fnbr),
44    bentf,
45    c_len=c_len)
46sys.exit(0)
47