create_ini.py 2.04 KB
Newer Older
1
2
3
import sys
import glob

4
def general(f, resizes, matrix_tam, comm_tam, sdr, adr, aib, time):
5
6
7
    f.write("[general]\n")
    f.write("resizes=" + resizes +"\n")
    f.write("matrix_tam=" + matrix_tam +"\n")
8
    f.write("comm_tam=" + comm_tam +"\n")
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
    f.write("SDR=" + sdr +"\n")
    f.write("ADR=" + adr +"\n")
    f.write("AIB=" + aib +"\n")
    f.write("time=" + time +"\n")
    f.write("; end [general]\n")

def resize_section(f, resize, iters, procs, factor, physical_dist):
    f.write("[resize" + resize + "]\n")
    f.write("iters=" + iters +"\n")
    f.write("procs=" + procs +"\n")
    f.write("factor=" + factor +"\n")
    f.write("physical_dist=" + physical_dist +"\n")
    f.write(";end [resize" + resize +"]\n")

if len(sys.argv) < 2:
  print("The config file name is missing\nUsage: python3 program nameFile args\nArgs: resizes matrix_tam SDR ADR AIB time iters0 procs0 dist0 iters1 procs1 dist1 ...")
  exit(1)

if len(sys.argv) < 12:
  print("The are not enough arguments\nUsage: python3 program nameFile args\nArgs: resizes matrix_tam SDR ADR_perc AIB time proc_time iters0 procs0 dist0 iters1 procs1 dist1 ...")
  exit(1)

name = sys.argv[1]
resizes = int(sys.argv[2])
matrix_tam = sys.argv[3]
34
35
36
37
38
39
comm_tam = sys.argv[4]
sdr = int(sys.argv[5])
adr_perc = float(sys.argv[6])
aib = sys.argv[7]
time = sys.argv[8]
proc_time = float(sys.argv[9]) # Usado para calcular el factor de cada proceso
40
41
42
43
44
45
46

adr = (sdr * adr_perc) / 100
sdr = sdr - adr

adr = str(adr)
sdr = str(sdr)

47
factor = 0
48
f = open(name, "w")
49
general(f, str(resizes), matrix_tam, comm_tam, sdr, adr, aib, time)
50
51
52

resizes = resizes + 1 # Internamente, los primeros procesos se muestran como un grupo
for resize in range(resizes):
53
54
55
    iters = sys.argv[10 + 3 * resize]
    procs = sys.argv[10 + 3 * resize + 1]
    physical_dist = sys.argv[10 + 3 * resize + 2]
56
57
58
59
60

    if proc_time != 0: # Si el argumento proc_time es 0, todos los grupos tienen un factor de 1
        factor = proc_time / float(procs)
    else:
        factor = 1
61
62
63
64
65

    resize_section(f, str(resize), iters, procs, str(factor), physical_dist)

f.close()
exit(1)