1 -- Copyright (c) 2011-2021. The SimGrid Team.
2 -- All rights reserved.
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.
17 function my_cluster(args)
18 -- args is a table with the following keys
20 local required_args = {"id", "prefix", "suffix", "radical", "speed", "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
24 if args.sharing_sharing_policy == nil then
25 args.sharing_sharing_policy = "SHARED"
27 if args.topology ~= "TORUS" and args.topology ~= "FAT_TREE" then
28 args.topology = "Cluster"
31 -- Check the mode = Cluster here
34 simgrid.engine.AS_open{id=args.id,mode=args.topology};
36 if args.bb_bw ~= nil and args.bb_lat ~= nil then
37 simgrid.engine.backbone_new{id=args.id .. "-bb",bandwidth=args.bb_bw,latency=args.bb_lat,sharing_policy=args.bb_sharing_sharing_policy}
39 for _,i in pairs(args.radical) do
40 local hostname = args.prefix .. i .. args.suffix
41 local linkname = args.id .."_link_" .. i
42 simgrid.engine.host_new{id=hostname, speed=args.speed,core=args.core,power_trace=args.availability_file,state_trace=args.state_file};
43 simgrid.engine.link_new{id=linkname, bandwidth=args.bw,latency=args.lat, sharing_policy=args.sharing_sharing_policy};
44 simgrid.engine.host_link_new{id=hostname,up=linkname.."_UP",down=linkname.."_DOWN"};
46 if args.loopback_bw ~= nil and args.loopback_lat ~= nil then
47 simgrid.engine.link_new{id=linkname .. "_loopback",bandwidth=args.loopback_bw,latency=args.loopback_lat,sharing_policy="FATPIPE"}
50 simgrid.engine.AS_seal()
54 simgrid.engine.open();
55 cluster_factory = my_cluster{prefix="node-", suffix=".simgrid.org", radical=seq(0,262144), host_factory = function(hostno)
56 if hostno % 2 == 0 then return "blabla" end
57 if hostno % 2 == 1 then return "blublub" end
63 sharing_sharing_policy="SPLITDUPLEX"
65 --my_cluster{prefix="node2-", suffix=".simgrid.org", radical=seq(0,44) }
67 simgrid.engine.close();