Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merging changes done by Steven, Samuel and Luka, regarding simulation of StarPU-MPI
[simgrid.git] / examples / platforms / cluster_prototype.lua
1 -- Copyright (c) 2011, 2014. The SimGrid Team.
2 -- All rights reserved.
3
4 -- This program is free software; you can redistribute it and/or modify it
5 -- under the terms of the license (GNU LGPL) which comes with this package.
6
7   require("simgrid")
8
9   function seq(min,max)
10     L={}
11     for i=min,max,1 do
12       table.insert(L,i)
13     end
14     return L
15   end
16
17   function my_cluster(args)
18     -- args is a table with the following keys
19     --   -
20     local required_args = {"id", "prefix", "suffix", "radical", "power", "bw", "lat" }
21     for _,val in pairs(required_args) do
22       if args[val] == nil then simgrid.critical("Must specify '" .. val .. "' attribute. See docs for details.") end
23     end
24     if args.sharing_sharing_policy == nil then
25         args.sharing_sharing_policy = "SHARED"
26     end
27     if args.topology ~= "TORUS" and args.topology ~= "FAT_TREE" then
28         args.topology = "Cluster"
29     end
30     --if args.core==nil   then args.core = 1 end
31     --if args.core==nil   then args.core = 1 end
32     --if args.core==nil   then args.core = 1 end
33     --if args.core==nil   then args.core = 1 end
34     --if args.core==nil   then args.core = 1 end
35     --if args.core==nil   then args.core = 1 end
36     --if args.core==nil   then args.core = 1 end
37     --if args.core==nil   then args.core = 1 end
38     --if args.core==nil   then args.core = 1 end
39
40     -- Check the mode = Cluster here
41     return function()
42
43         simgrid.platf.AS_open{id=args.id,mode=args.topology};
44
45         if args.bb_bw ~= nil and args.bb_lat ~= nil then
46           simgrid.platf.backbone_new{id=args.id .. "-bb",bandwidth=args.bb_bw,latency=args.bb_lat,sharing_policy=args.bb_sharing_sharing_policy}
47         end
48         for _,i in pairs(args.radical) do
49             local hostname = args.prefix .. i .. args.suffix
50             local linkname = args.id .."_link_" .. i
51             simgrid.platf.host_new{id=hostname, power=args.power,core=args.core,power_trace=args.availability_file,state_trace=args.state_file};
52             simgrid.platf.link_new{id=linkname, bandwidth=args.bw,latency=args.lat, sharing_policy=args.sharing_sharing_policy};
53             simgrid.platf.host_link_new{id=hostname,up=linkname.."_UP",down=linkname.."_DOWN"};
54
55             if args.loopback_bw ~= nil and args.loopback_lat ~= nil then
56               simgrid.platf.link_new{id=linkname .. "_loopback",bandwidth=args.loopback_bw,latency=args.loopback_lat,sharing_policy="FATPIPE"}
57             end
58         end
59         simgrid.platf.AS_close()
60       end
61   end
62
63   simgrid.platf.open();
64   cluster_factory = my_cluster{prefix="node-", suffix=".acme.org", radical=seq(0,262144), host_factory = function(hostno)
65       if hostno % 2 == 0 then return "blabla" end
66       if hostno % 2 == 1 then return "blublub" end
67     end,
68     power="1Gf",
69     id="AS0",
70     bw="125MBps",
71     lat="50us",
72     sharing_sharing_policy="FULLDUPLEX"
73   }()
74   --my_cluster{prefix="node2-", suffix=".acme.org", radical=seq(0,44) }
75
76   simgrid.platf.close();