From 48e17fb4a61265f26702ed02426d825558c3d0bf Mon Sep 17 00:00:00 2001 From: Cotton Seed Date: Thu, 2 Aug 2012 19:05:51 -0400 Subject: [PATCH] Build on newcomp with clang++. Added .cmd files for newcomp q. --- .gitignore | 3 ++- Makefile | 12 +++++----- algebra/algebra.cpp | 20 ++++++++-------- knot_tables.cpp | 6 ++--- lib/lib.h | 3 +++ main.cpp | 43 ++++++++++++++++++++++++++++++++- mpimain.cpp | 58 ++++++++++++++++++--------------------------- parallel.cmd | 20 ++++++++++++++++ serial.cmd | 15 ++++++++++++ 9 files changed, 124 insertions(+), 56 deletions(-) create mode 100644 parallel.cmd create mode 100644 serial.cmd diff --git a/.gitignore b/.gitignore index 2368d6d..fec3496 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ /gss /main /testsurfaces -/serial.cmd* +/serial.cmd.[eo]* +/parallel.cmd.[eo]* /save */save diff --git a/Makefile b/Makefile index a9388df..0aabbf9 100644 --- a/Makefile +++ b/Makefile @@ -3,16 +3,16 @@ BISON = /opt/local/bin/bison FLEX = /opt/local/bin/flex # CXX = g++ -# CXX = mpic++ -CXX = clang++ -fno-color-diagnostics --stdlib=libc++ --std=c++11 +CXX = OMPI_CXX=clang++ mpic++ -fno-color-diagnostics --stdlib=libc++ --std=c++11 -I/u/cseed/llvm-3.1/lib/c++/v1 +# CXX = clang++ -fno-color-diagnostics --stdlib=libc++ --std=c++11 INCLUDES = -I/opt/local/include -I. # OPTFLAGS = -g -OPTFLAGS = -O2 -g -# OPTFLAGS = -O2 -DNDEBUG +# OPTFLAGS = -O2 -g +OPTFLAGS = -O2 -DNDEBUG -LDFLAGS = -L/opt/local/lib +LDFLAGS = -L/opt/local/lib -L/u/cseed/llvm-3.1/lib # LDFLAGS = -pg -L/opt/local/lib CXXFLAGS = $(OPTFLAGS) -Wall -Wno-unused $(INCLUDES) @@ -95,7 +95,7 @@ parser_files: \ .PHONY: clean clean: rm -f *.o lib/*.o algebra/*.o knot_parser/*.o rd_parser/*.o - rm -f main gss + rm -f main gss mpimain rm -f gmon.out .PHONY: realclean diff --git a/algebra/algebra.cpp b/algebra/algebra.cpp index 451f4cb..82b01a2 100644 --- a/algebra/algebra.cpp +++ b/algebra/algebra.cpp @@ -16,8 +16,8 @@ unsigned_gcd (unsigned a, unsigned b) unsigned int_gcd (int a, int b) { - return unsigned_gcd ((unsigned)std::abs (a), - (unsigned)std::abs (b)); + return unsigned_gcd ((unsigned)abs (a), + (unsigned)abs (b)); } uint64 @@ -35,8 +35,8 @@ uint64_gcd (uint64 a, uint64 b) uint64 int64_gcd (int64 a, int64 b) { - return uint64_gcd ((uint64)std::abs (a), - (uint64)std::abs (b)); + return uint64_gcd ((uint64)abs64 (a), + (uint64)abs64 (b)); } static tuple @@ -71,8 +71,8 @@ unsigned_extended_gcd (unsigned a, unsigned b) tuple extended_gcd (int a, int b) { - tuple t = extended_gcd_1 (std::abs (a), - std::abs (b)); + tuple t = extended_gcd_1 (abs (a), + abs (b)); unsigned d = get<0> (t); int x = get<1> (t), y = get<2> (t); @@ -100,12 +100,12 @@ uint64_lcm (uint64 a, uint64 b) unsigned int_lcm (int a, int b) { - return unsigned_lcm ((unsigned)std::abs (a), - (unsigned)std::abs (b)); + return unsigned_lcm ((unsigned)abs (a), + (unsigned)abs (b)); } uint64 int64_lcm (int64 a, int64 b) { - return uint64_lcm ((uint64)std::abs (a), - (uint64)std::abs (b)); + return uint64_lcm ((uint64)abs64 (a), + (uint64)abs64 (b)); } diff --git a/knot_tables.cpp b/knot_tables.cpp index a9d8739..f63b170 100644 --- a/knot_tables.cpp +++ b/knot_tables.cpp @@ -1,7 +1,7 @@ #include -#define HOME "/Users/cotton/src/knotkit/" +#define HOME "/u/cseed/src/knotkit/" bool verbose = 0; @@ -642,7 +642,7 @@ braid (unsigned n_strands, const basedvector &twists) last_twist[i] = 0; for (unsigned i = 1; i <= twists.size (); i ++) { - unsigned t = std::abs (twists[i]); + unsigned t = abs (twists[i]); last_twist[t] = i; last_twist[t + 1] = i; } @@ -657,7 +657,7 @@ braid (unsigned n_strands, const basedvector &twists) for (unsigned i = 1; i <= twists.size (); i ++) { - unsigned t = std::abs (twists[i]); + unsigned t = abs (twists[i]); unsigned e1 = strands[t], e4 = strands[t + 1]; unsigned e2, e3; diff --git a/lib/lib.h b/lib/lib.h index 0a7faa8..1bb300c 100644 --- a/lib/lib.h +++ b/lib/lib.h @@ -1,5 +1,6 @@ #include +#include #include #include #include @@ -39,6 +40,8 @@ typedef unsigned long ulong; typedef long long int64; typedef unsigned long long uint64; +inline int64 abs64 (int64 x) { return llabs (x); } + typedef size_t hash_t; static const unsigned uint8_bits = 8; diff --git a/main.cpp b/main.cpp index e731b2e..14238d3 100644 --- a/main.cpp +++ b/main.cpp @@ -692,12 +692,53 @@ test_knot_sq () } } +pair, mod_map > +compute_kh_sq (const knot_desc &desc) +{ +} + int main () { +#if 1 + knot_desc desc; + desc.t = knot_desc::HTW; + desc.i = 15; + desc.j = 15020; + + char buf[1000]; + sprintf (buf, "/scratch/network/cseed/incoming/K%d_%d.dat.gz", + desc.i, desc.j); + + desc = knot_desc (knot_desc::ROLFSEN, 3, 1); + + knot_diagram kd = desc.diagram (); + + cube c (kd); + mod_map d = c.compute_d (1, 0, 0, 0, 0); + + chain_complex_simplifier s (c.khC, d, 1); + assert (s.new_d == 0); + + steenrod_square sq (c, d, s); + mod_map sq1 = sq.sq1 (); + mod_map sq2 = sq.sq2 (); + + assert (sq1.compose (sq1) == 0); + assert (sq2.compose (sq2) + sq1.compose (sq2).compose (sq1) == 0); + +#if 1 + { + file_writer w (buf); + write (w, sq1); + write (w, sq2); + } +#endif +#endif + return 0; + // convert_knot_sq (); test_knot_sq (); - return 0; // test_sage_show (); dump_sage (); diff --git a/mpimain.cpp b/mpimain.cpp index 193895a..5b46508 100644 --- a/mpimain.cpp +++ b/mpimain.cpp @@ -87,32 +87,6 @@ master () } } -pair, mod_map > -compute_kh_sq (const knot_desc &desc) -{ - knot_diagram kd = desc.diagram (); - - unsigned rank = self_rank (); - - printf ("[% 2d] %s\n", rank, kd.name.c_str ()); - fflush (stdout); - - cube c (kd); - mod_map d = c.compute_d (1, 0, 0, 0, 0); - - chain_complex_simplifier s (c.khC, d, 1); - assert (s.new_d == 0); - - steenrod_square sq (c, d, s); - mod_map sq1 = sq.sq1 (); - mod_map sq2 = sq.sq2 (); - - assert (sq1.compose (sq1) == 0); - assert (sq2.compose (sq2) + sq1.compose (sq2).compose (sq1) == 0); - - return pair, mod_map > (sq1, sq2); -} - void slave () { @@ -127,21 +101,35 @@ slave () { knot_desc desc; desc.t = (knot_desc::table)recv_int (); - desc.i = (knot_desc::table)recv_int (); - desc.j = (knot_desc::table)recv_int (); + desc.i = (unsigned)recv_int (); + desc.j = (unsigned)recv_int (); printf ("[% 2d] CMD_DO %s\n", rank, desc.name ().c_str ()); char buf[1000]; - sprintf (buf, "incoming/K%d_%d.dat", desc.i, desc.j); + sprintf (buf, "/scratch/network/cseed/incoming/K%d_%d.dat.gz", + desc.i, desc.j); - pair, mod_map > p = compute_kh_sq (knot_kh_sq, desc); + // desc = knot_desc (knot_desc::ROLFSEN, 3, 1); - { - writer w (buf); - write (w, p.first); - write (w, p.second); - } + knot_diagram kd = desc.diagram (); + + cube c (kd); + mod_map d = c.compute_d (1, 0, 0, 0, 0); + + chain_complex_simplifier s (c.khC, d, 1); + assert (s.new_d == 0); + + steenrod_square sq (c, d, s); + mod_map sq1 = sq.sq1 (); + mod_map sq2 = sq.sq2 (); + + assert (sq1.compose (sq1) == 0); + assert (sq2.compose (sq2) + sq1.compose (sq2).compose (sq1) == 0); + + file_writer w (buf); + write (w, sq1); + write (w, sq2); send_int (0, 0); } diff --git a/parallel.cmd b/parallel.cmd new file mode 100644 index 0000000..78ceece --- /dev/null +++ b/parallel.cmd @@ -0,0 +1,20 @@ +# mpi job, runtime max 5days +#PBS -l nodes=2:ppn=6,walltime=96:00:00 +# xxx PBS -l mem=80gb +# +# sends mail if the process aborts, when it begins, and +# when it ends (abe) +#PBS -m abe +# +module load openmpi/gcc +# go to the directory with the program +cd $HOME/src/knotkit + +LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/u/cseed/llvm-3.1/lib +export LD_LIBRARY_PATH + +echo $LD_LIBRARY_PATH + +# and run it +numprocs=`wc -l <${PBS_NODEFILE}` +mpiexec -np $numprocs ./mpimain diff --git a/serial.cmd b/serial.cmd new file mode 100644 index 0000000..cba1fc0 --- /dev/null +++ b/serial.cmd @@ -0,0 +1,15 @@ +# serial job +#PBS -l nodes=1:ppn=1,walltime=96:00:00 +# xxx PBS -l mem=80gb +# +# sends mail if the process aborts, when it begins, and +# when it ends (abe) +#PBS -m abe +# +# load intel compiler settings before running the program +# since we compiled it with intel 10.1 +# module load intel/10.1 +# go to the directory with the program +cd $HOME/src/knotkit +# and run it +./main