create_ini.py 1.82 KB
Newer Older
1
2
3
4
5
6
7
8
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import sys
import glob

def general(f, resizes, matrix_tam, sdr, adr, aib, time):
    f.write("[general]\n")
    f.write("resizes=" + resizes +"\n")
    f.write("matrix_tam=" + matrix_tam +"\n")
    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]
sdr = int(sys.argv[4])
adr_perc = float(sys.argv[5])
aib = sys.argv[6]
time = sys.argv[7]
proc_time = float(sys.argv[8]) # Usado para calcular el factor de cada proceso

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

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

f = open(name, "w")
general(f, str(resizes), matrix_tam, sdr, adr, aib, time)

resizes = resizes + 1 # Internamente, los primeros procesos se muestran como un grupo
for resize in range(resizes):
    iters = sys.argv[9 + 3 * resize]
    procs = sys.argv[9 + 3 * resize + 1]
    physical_dist = sys.argv[9 + 3 * resize + 2]
    factor = proc_time / float(procs)

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

f.close()
exit(1)