~ubuntu-branches/ubuntu/saucy/freecell-solver/saucy

« back to all changes in this revision

Viewing changes to scripts/prepare_fcc_solver_self_contained_package.pl

  • Committer: Package Import Robot
  • Author(s): Gergely Risko
  • Date: 2012-06-22 10:08:05 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20120622100805-evoda1ccdr8vt5xr
Tags: 3.12.0-1
New upstream version. (closes: #675262)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
 
 
3
use strict;
 
4
use warnings;
 
5
 
 
6
use IO::All;
 
7
use File::Path;
 
8
 
 
9
use Getopt::Long;
 
10
 
 
11
my $to_upload = 0;
 
12
GetOptions(
 
13
    '--upload!' => \$to_upload,
 
14
);
 
15
 
 
16
my $dest_dir = 'fcc_solver_for_amadiro';
 
17
mkpath("$dest_dir");
 
18
mkpath("$dest_dir/pthread");
 
19
mkpath("$dest_dir/libavl");
 
20
 
 
21
system(qq{./Tatzer -l x64b --nfc=2 --states-type=COMPACT_STATES --dbm=kaztree});
 
22
my @modules = ('app_str.o', 'card.o', 'fcc_solver.o', 'state.o', 'kaz_tree.o', 'rwlock.o', 'queue.o', 'meta_alloc.o', 'libavl/avl.o', );
 
23
 
 
24
foreach my $fn ('alloc.c', 'app_str.c', 'card.c', 'dbm_solver.c', 'state.c',
 
25
    'dbm_kaztree.c', 'alloc.h', 'card.h', 'config.h', 'state.h',
 
26
    'dbm_solver.h', 'kaz_tree.c', 'kaz_tree.h', 'dbm_solver_key.h',
 
27
    'fcs_move.h', 'inline.h', 'bool.h', 'internal_move_struct.h', 'app_str.h',
 
28
    'delta_states.c', 'fcs_dllexport.h', 'bit_rw.h', 'fcs_enums.h', 'unused.h',
 
29
    'portable_time.h', 'dbm_calc_derived.h', 'dbm_calc_derived_iface.h',
 
30
    'dbm_common.h', 'fcc_solver.c', 'indirect_buffer.h', 'fcc_brfs_test.h',
 
31
    'fcc_brfs.h', 'dbm_lru_cache.h', 'dbm_cache.h', 'meta_alloc.h',
 
32
    'meta_alloc.c', 'libavl/avl.c',, 'libavl/avl.h', 'generic_tree.h',
 
33
    'delta_states.h',
 
34
)
 
35
{
 
36
    io($fn) > io("$dest_dir/$fn");
 
37
}
 
38
 
 
39
foreach my $fn ('rwlock.c', 'queue.c', 'pthread/rwlock_fcfs.h', 'pthread/rwlock_fcfs_queue.h')
 
40
{
 
41
    io("/home/shlomif/progs/C/pthreads/rwlock/fcfs-rwlock/pthreads/$fn") > io("$dest_dir/$fn")
 
42
}
 
43
 
 
44
my $cache_size = 64_000_000;
 
45
my @deals = (
 
46
    982,
 
47
);
 
48
 
 
49
# my $deal_idx = 982;
 
50
foreach my $deal_idx (@deals)
 
51
{
 
52
    system(qq{python board_gen/make_pysol_freecell_board.py -t --ms $deal_idx > $dest_dir/$deal_idx.board});
 
53
}
 
54
 
 
55
@modules = sort { $a cmp $b } @modules;
 
56
 
 
57
io("$dest_dir/Makefile")->print(<<"EOF");
 
58
TARGET = fcc_fc_solver
 
59
DEALS = @deals
 
60
 
 
61
DEALS_DUMPS = \$(patsubst %,%.dump,\$(DEALS))
 
62
THREADS = 12
 
63
CACHE_SIZE = $cache_size
 
64
 
 
65
CFLAGS = -O3 -march=native -fomit-frame-pointer -DFCS_DBM_WITHOUT_CACHES=1 -DFCS_DBM_USE_LIBAVL=1 -I. -I./libavl/
 
66
MODULES = @modules
 
67
 
 
68
all: \$(TARGET)
 
69
 
 
70
\$(TARGET): \$(MODULES)
 
71
\tgcc \$(CFLAGS) -fwhole-program -o \$\@ \$(MODULES) -lm -lpthread
 
72
 
 
73
\$(MODULES): %.o: %.c
 
74
\tgcc -c \$(CFLAGS) -o \$\@ \$<
 
75
 
 
76
run: \$(DEALS_DUMPS)
 
77
 
 
78
\$(DEALS_DUMPS): %.dump: all
 
79
\t./\$(TARGET) --caches-delta \$(CACHE_SIZE) -o \$\@ \$(patsubst %.dump,%.board,\$\@)
 
80
 
 
81
%.show:
 
82
\t\@echo "\$* = \$(\$*)"
 
83
EOF
 
84
 
 
85
if ($to_upload)
 
86
{
 
87
    my $arc_name = "$dest_dir-trunk-r4442.tar.bz2";
 
88
    if (system('tar', '-cjvf', $arc_name, $dest_dir))
 
89
    {
 
90
        die "tar failed!";
 
91
    }
 
92
    system("rsync", "-a", "-v", "--progress", "--inplace", $arc_name,
 
93
        "hostgator:public_html/Files/files/code/"
 
94
    );
 
95
}