Browse code

moved computation inside if statement

Tom Sherman authored on 03/08/2018 19:58:43
Showing5 changed files

... ...
@@ -12,6 +12,7 @@ env:
12 12
   global:
13 13
     - TMPDIR=$HOME
14 14
 
15
+# make sure configure is executable
15 16
 before_install:
16 17
   - chmod +x configure
17 18
 
... ...
@@ -1,6 +1,6 @@
1 1
 #! /bin/sh
2 2
 # Guess values for system-dependent variables and create Makefiles.
3
-# Generated by GNU Autoconf 2.69 for CoGAPS 3.3.1.
3
+# Generated by GNU Autoconf 2.69 for CoGAPS 3.3.2.
4 4
 #
5 5
 #
6 6
 # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
... ...
@@ -577,8 +577,8 @@ MAKEFLAGS=
577 577
 # Identity of this package.
578 578
 PACKAGE_NAME='CoGAPS'
579 579
 PACKAGE_TARNAME='cogaps'
580
-PACKAGE_VERSION='3.3.1'
581
-PACKAGE_STRING='CoGAPS 3.3.1'
580
+PACKAGE_VERSION='3.3.2'
581
+PACKAGE_STRING='CoGAPS 3.3.2'
582 582
 PACKAGE_BUGREPORT=''
583 583
 PACKAGE_URL=''
584 584
 
... ...
@@ -698,6 +698,7 @@ enable_dependency_tracking
698 698
 enable_debug
699 699
 enable_warnings
700 700
 enable_simd
701
+enable_openmp
701 702
 '
702 703
       ac_precious_vars='build_alias
703 704
 host_alias
... ...
@@ -1261,7 +1262,7 @@ if test "$ac_init_help" = "long"; then
1261 1262
   # Omit some internal or obsolete options to make the list less imposing.
1262 1263
   # This message is too long to be a string in the A/UX 3.1 sh.
1263 1264
   cat <<_ACEOF
1264
-\`configure' configures CoGAPS 3.3.1 to adapt to many kinds of systems.
1265
+\`configure' configures CoGAPS 3.3.2 to adapt to many kinds of systems.
1265 1266
 
1266 1267
 Usage: $0 [OPTION]... [VAR=VALUE]...
1267 1268
 
... ...
@@ -1332,7 +1333,7 @@ fi
1332 1333
 
1333 1334
 if test -n "$ac_init_help"; then
1334 1335
   case $ac_init_help in
1335
-     short | recursive ) echo "Configuration of CoGAPS 3.3.1:";;
1336
+     short | recursive ) echo "Configuration of CoGAPS 3.3.2:";;
1336 1337
    esac
1337 1338
   cat <<\_ACEOF
1338 1339
 
... ...
@@ -1349,6 +1350,7 @@ Optional Features:
1349 1350
   --enable-debug          build debug version of CoGAPS
1350 1351
   --enable-warnings       compile CoGAPS with warning messages
1351 1352
   --enable-simd           specify simd instruction set (sse, avx)
1353
+  --enable-openmp         compile with openMP support if available
1352 1354
 
1353 1355
 Some influential environment variables:
1354 1356
   CXX         C++ compiler command
... ...
@@ -1428,7 +1430,7 @@ fi
1428 1430
 test -n "$ac_init_help" && exit $ac_status
1429 1431
 if $ac_init_version; then
1430 1432
   cat <<\_ACEOF
1431
-CoGAPS configure 3.3.1
1433
+CoGAPS configure 3.3.2
1432 1434
 generated by GNU Autoconf 2.69
1433 1435
 
1434 1436
 Copyright (C) 2012 Free Software Foundation, Inc.
... ...
@@ -1871,7 +1873,7 @@ cat >config.log <<_ACEOF
1871 1873
 This file contains any messages produced by compilers while
1872 1874
 running configure, to aid debugging if configure makes a mistake.
1873 1875
 
1874
-It was created by CoGAPS $as_me 3.3.1, which was
1876
+It was created by CoGAPS $as_me 3.3.2, which was
1875 1877
 generated by GNU Autoconf 2.69.  Invocation command line was
1876 1878
 
1877 1879
   $ $0 $@
... ...
@@ -2734,7 +2736,7 @@ fi
2734 2736
 
2735 2737
 # Define the identity of the package.
2736 2738
  PACKAGE='cogaps'
2737
- VERSION='3.3.1'
2739
+ VERSION='3.3.2'
2738 2740
 
2739 2741
 
2740 2742
 cat >>confdefs.h <<_ACEOF
... ...
@@ -5129,7 +5131,16 @@ fi
5129 5131
 $as_echo "$ax_cv_cxx_compiler_version" >&6; }
5130 5132
 
5131 5133
 
5132
-# set openmp flags
5134
+# set openmp flags, disable only if requested
5135
+# Check whether --enable-openmp was given.
5136
+if test "${enable_openmp+set}" = set; then :
5137
+  enableval=$enable_openmp; use_openmp=$enableval
5138
+else
5139
+  use_openmp=yes
5140
+fi
5141
+
5142
+
5143
+if test "x$use_openmp" != "xno" ; then
5133 5144
 
5134 5145
 
5135 5146
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenMP flag of C++ compiler" >&5
... ...
@@ -5196,8 +5207,9 @@ $as_echo "#define HAVE_OPENMP 1" >>confdefs.h
5196 5207
 
5197 5208
 fi
5198 5209
 
5199
-GAPS_CXX_FLAGS+=" $OPENMP_CXXFLAGS "
5200
-GAPS_LIBS+=" $OPENMP_CXXFLAGS "
5210
+    GAPS_CXX_FLAGS+=" $OPENMP_CXXFLAGS "
5211
+    GAPS_LIBS+=" $OPENMP_CXXFLAGS "
5212
+fi
5201 5213
 
5202 5214
 # detect SIMD support
5203 5215
 # Make sure we can run config.sub.
... ...
@@ -7460,7 +7472,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
7460 7472
 # report actual input values of CONFIG_FILES etc. instead of their
7461 7473
 # values after options handling.
7462 7474
 ac_log="
7463
-This file was extended by CoGAPS $as_me 3.3.1, which was
7475
+This file was extended by CoGAPS $as_me 3.3.2, which was
7464 7476
 generated by GNU Autoconf 2.69.  Invocation command line was
7465 7477
 
7466 7478
   CONFIG_FILES    = $CONFIG_FILES
... ...
@@ -7517,7 +7529,7 @@ _ACEOF
7517 7529
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
7518 7530
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
7519 7531
 ac_cs_version="\\
7520
-CoGAPS config.status 3.3.1
7532
+CoGAPS config.status 3.3.2
7521 7533
 configured by $0, generated by GNU Autoconf 2.69,
7522 7534
   with options \\"\$ac_cs_config\\"
7523 7535
 
... ...
@@ -32,10 +32,16 @@ GAPS_LIBS=
32 32
 AX_COMPILER_VENDOR
33 33
 AX_COMPILER_VERSION
34 34
 
35
-# set openmp flags
35
+# set openmp flags, disable only if requested
36
+AC_ARG_ENABLE(openmp, [AC_HELP_STRING([--enable-openmp],
37
+    [compile with openMP support if available])],
38
+    [use_openmp=$enableval], [use_openmp=yes])
39
+
36 40
 AX_OPENMP
37
-GAPS_CXX_FLAGS+=" $OPENMP_CXXFLAGS "
38
-GAPS_LIBS+=" $OPENMP_CXXFLAGS "
41
+if test "x$use_openmp" != "xno" ; then
42
+    GAPS_CXX_FLAGS+=" $OPENMP_CXXFLAGS "
43
+    GAPS_LIBS+=" $OPENMP_CXXFLAGS "
44
+fi
39 45
 
40 46
 # detect SIMD support
41 47
 AX_EXT
... ...
@@ -520,11 +520,16 @@ template <class T, class MatA, class MatB>
520 520
 void GibbsSampler<T, MatA, MatB>::exchange(uint64_t p1, float m1, uint64_t p2,
521 521
 float m2, unsigned r1, unsigned c1, unsigned r2, unsigned c2)
522 522
 {
523
-    float pUpper = gaps::random::p_gamma(m1 + m2, 2.f, 1.f / mLambda);
524
-    float newMass = gaps::random::inverseGammaSample(0.f, pUpper, 2.f, 1.f / mLambda);
525 523
     if (r1 != r2 || c1 != c2) // automatically reject if change in same bin
526 524
     {
527
-        if ((m1 > m2 && newMass - m1 < 0) || (m2 > m1 && m2 - newMass < 0))
525
+        float pUpper = gaps::random::p_gamma(m1 + m2, 2.f, 1.f / mLambda);
526
+        float newMass = gaps::random::inverseGammaSample(0.f, pUpper, 2.f, 1.f / mLambda);
527
+
528
+        // swapping only effects alpha parameters - only effects gibbs
529
+        // flips the sign of alpha parameters (only su)
530
+        // flips sign in gibbs mass
531
+        // can we swap after gibbsMass calculation?
532
+        if ((m1 > m2 && m1 > newMass) || (m2 > m1 && m2 < newMass))
528 533
         {
529 534
             std::swap(r1, r2);
530 535
             std::swap(c1, c2);
... ...
@@ -105,6 +105,8 @@ public:
105 105
     void load(const float *ptr) { mData = LOAD_PACKED(ptr); }
106 106
     void store(float *ptr) { STORE_PACKED(ptr, mData); }
107 107
 
108
+// RTTI may be expensive
109
+
108 110
 #if defined( __GAPS_AVX__ )
109 111
     float scalar()
110 112
     {