-
Notifications
You must be signed in to change notification settings - Fork 0
/
barnes_hut_io.rg
58 lines (52 loc) · 1.52 KB
/
barnes_hut_io.rg
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 "regent"
require("barnes_hut_common")
local c = regentlib.c
local cstring = terralib.includec("string.h")
local std = terralib.includec("stdlib.h")
struct Config {
time_steps : uint,
input_file : rawstring,
input_file_set : bool,
num_bodies : uint,
parallelism : uint,
leaf_size : uint
fixed_partition_size : uint,
max_depth : uint,
}
terra parse_input_args()
var conf : Config
conf.time_steps = 10
conf.input_file_set = false
conf.num_bodies = -1
conf.leaf_size = 32
conf.parallelism = 16
conf.fixed_partition_size = -1
conf.max_depth = -1
var args = c.legion_runtime_get_input_args()
for i = 0, args.argc do
if cstring.strcmp(args.argv[i], "-i") == 0 then
i = i + 1
conf.input_file = args.argv[i]
conf.input_file_set = true
elseif cstring.strcmp(args.argv[i], "-n") == 0 then
i = i + 1
conf.num_bodies = std.atoi(args.argv[i])
elseif cstring.strcmp(args.argv[i], "-t") == 0 then
i = i + 1
conf.time_steps = std.atoi(args.argv[i])
elseif cstring.strcmp(args.argv[i], "-p") == 0 then
i = i + 1
conf.parallelism = std.atoi(args.argv[i])
elseif cstring.strcmp(args.argv[i], "-l") == 0 then
i = i + 1
conf.leaf_size = std.atoi(args.argv[i])
elseif cstring.strcmp(args.argv[i], "-x") == 0 then
i = i + 1
conf.fixed_partition_size = std.atoi(args.argv[i])
elseif cstring.strcmp(args.argv[i], "-m") == 0 then
i = i + 1
conf.max_depth = std.atoi(args.argv[i])
end
end
return conf
end