CoCalc Public FilesBoolean-Cayley-graphs / sage-code / save_cast128_in_mpi_parallel.pyOpen with one click!
Author: Paul Leopardi
Compute Environment: Ubuntu 18.04 (Deprecated)
1
r"""
2
"""
3
#*****************************************************************************
4
# Copyright (C) 2017 Paul Leopardi [email protected]
5
#
6
# Distributed under the terms of the GNU General Public License (GPL)
7
# as published by the Free Software Foundation; either version 2 of
8
# the License, or (at your option) any later version.
9
# http://www.gnu.org/licenses/
10
#*****************************************************************************
11
12
import sys
13
14
from mpi4py import MPI
15
from sage.all_cmdline import *
16
17
from boolean_cayley_graphs.classify_in_mpi_parallel import save_class_parts_in_parallel
18
19
r"""
20
"""
21
# Check that the correct number of arguments exist.
22
if 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.
27
bnbr = int(sys.argv[1]) # S-box number
28
fnbr = int(sys.argv[2]) # Function number within S-box
29
c_len = int(sys.argv[3]) # Number of c values per class part.
30
31
# Get our MPI rank.
32
comm = MPI.COMM_WORLD
33
rank = comm.Get_rank()
34
35
# Load the required bent function.
36
load("read_cast_128_s_boxes.sage")
37
s_boxes = read_s_boxes_file()
38
bentf = s_boxes[bnbr][fnbr]
39
40
# Save the classification in parts with c_len matrix rows each.
41
save_class_parts_in_parallel(
42
comm,
43
"cast128_"+str(bnbr)+"_"+str(fnbr),
44
bentf,
45
c_len=c_len)
46
sys.exit(0)
47