Merge branch 'master' of github.com:JamesEMcClure/LBPM-WIA

This commit is contained in:
James E McClure 2015-03-20 12:25:30 -04:00
commit 0db3870c1c
7 changed files with 141 additions and 88 deletions

View File

@ -135,10 +135,11 @@ void ParallelStreamBuffer::reserve( size_t size )
}
}
}
std::streamsize ParallelStreamBuffer::xsputn( const std::string &text, std::streamsize n )
std::streamsize ParallelStreamBuffer::xsputn( const char* text, std::streamsize n )
{
reserve(d_size+n);
memcpy(&d_buffer[d_size],text.c_str(),text.size());
memcpy(&d_buffer[d_size],text,n);
d_size += n;
if ( text[n-1]==0 || text[n-1]==10 ) { sync(); }
return n;
}

View File

@ -73,7 +73,7 @@ public:
* Write the specified number of characters into the output stream (called
* from streambuf).
*/
virtual std::streamsize xsputn(const std::string &text, std::streamsize n);
virtual std::streamsize xsputn(const char* text, std::streamsize n);
/*!
* Write an overflow character into the parallel buffer (called from

View File

@ -6,7 +6,8 @@
# Set platform specific variables
SITE_NAME( HOSTNAME )
STRING(REGEX REPLACE "-ext." "" HOSTNAME "${HOSTNAME}")
STRING(REGEX REPLACE "-ext." "" HOSTNAME "${HOSTNAME}")
STRING(REGEX REPLACE "-login." "" HOSTNAME "${HOSTNAME}")
SET( CC $ENV{CC} )
SET( CXX $ENV{CXX} )
SET( CFLAGS $ENV{CFLAGS} )
@ -41,7 +42,8 @@ SET( BUILD_SERIAL $ENV{BUILD_SERIAL} )
SET( CUDA_FLAGS $ENV{CUDA_FLAGS} )
SET( CUDA_HOST_COMPILER $ENV{CUDA_HOST_COMPILER} )
SET( SKIP_TESTS $ENV{SKIP_TESTS} )
SET( BUILDNAME_POSTFIX "$ENV{BUILDNAME_POSTFIX}" )
SET( BUILDNAME_POSTFIX "$ENV{BUILDNAME_POSTFIX}" )
SET( LIB_TYPE "$ENV{LIB_TYPE}" )
# Get the source directory based on the current directory
@ -201,7 +203,7 @@ ELSE()
SET( CTEST_OPTIONS "${CTEST_OPTIONS};-DUSE_TIMER:BOOL=false" )
ENDIF()
IF ( USE_CUDA )
SET( CTEST_OPTIONS "${CTEST_OPTIONS};-DUSE_CUDA:BOOL=true;-DCUDA_NVCC_FLAGS='${CUDA_FLAGS}';-DCUDA_HOST_COMPILER=${CUDA_HOST_COMPILER};-DLIB_TYPE=SHARED" )
SET( CTEST_OPTIONS "${CTEST_OPTIONS};-DUSE_CUDA:BOOL=true;-DCUDA_NVCC_FLAGS='${CUDA_FLAGS}';-DCUDA_HOST_COMPILER=${CUDA_HOST_COMPILER};-DLIB_TYPE=${LIB_TYPE}" )
ELSE()
SET( CTEST_OPTIONS "${CTEST_OPTIONS};-DUSE_CUDA:BOOL=false" )
ENDIF()

View File

@ -33,19 +33,29 @@ ENDFUNCTION()
MACRO( CONFIGURE_CUDA )
CHECK_ENABLE_FLAG( USE_CUDA 0 )
IF( USE_CUDA )
SET( CUDA_FLAGS ${CUDA_NVCC_FLAGS} )
SET( CUDA_FIND_QUIETLY 1 )
INCLUDE ( FindCUDA )
# Include FindCUDA
INCLUDE( FindCUDA )
IF ( NOT CUDA_FOUND )
MESSAGE ( FATAL_ERROR "CUDA not found" )
ENDIF()
SET(CUDA_NVCC_FLAGS ${CUDA_FLAGS})
# Initialize the cuda flags
IF ( CUDA_FLAGS )
SET( CUDA_NVCC_FLAGS "${CUDA_FLAGS}" )
ENDIF()
IF(NOT CUDA_NVCC_FLAGS)
# Set minimum requirements
SET( CUDA_NVCC_FLAGS "-arch=sm_20" )
ELSE()
STRING( REPLACE " " ";" CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} )
ENDIF()
IF( NOT CMAKE_BUILD_TYPE )
MESSAGE(FATAL_ERROR "CMAKE_BUILD_TYPE is not set")
ELSEIF( ${CMAKE_BUILD_TYPE} STREQUAL "Debug" )
SET( CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -g -O0" )
ELSEIF( ${CMAKE_BUILD_TYPE} STREQUAL "Release" )
SET( CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -O3" )
ENDIF()
SET( CUDA_PROPAGATE_HOST_FLAGS OFF )
SET( CUDA_FIND_QUIETLY )
STRING( REPLACE " " ";" CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} )
ENDIF()
IF ( NOT USE_CUDA )
MESSAGE( "Not using CUDA" )

View File

@ -5,6 +5,7 @@
#include <math.h>
#include "Array.h"
#include "PointList.h"
#include "Utilities.h"
//#include "vecLib/clapack.h"
using namespace std;
@ -3775,14 +3776,14 @@ inline void pmmc_CommonCurveSpeed(DoubleArray &CubeValues, DoubleArray &dPdt, Do
{
int p;
double s,lwns,norm;
double a,b,c,d,e,f,g,h;
double x,y,z,zeta;
double zeta;
double tangent_x,tangent_y,tangent_z;
double ns_x, ns_y, ns_z;
double nwn_x, nwn_y, nwn_z;
double nwns_x, nwns_y, nwns_z;
Point P,A,B;
lwns = 0.0;
NULL_USE(lwns);
TriLinPoly Px,Py,Pz,SDx,SDy,SDz,Pt;
Px.assign(Fx,i,j,k);
@ -3875,6 +3876,9 @@ inline void pmmc_CommonCurveSpeed(DoubleArray &CubeValues, DoubleArray &dPdt, Do
ReturnVector(2) += zeta*nwns_z*s;
}
}
NULL_USE(tangent_x);
NULL_USE(tangent_y);
NULL_USE(tangent_z);
}
inline void pmmc_CurveOrientation(DoubleArray &Orientation, DTMutableList<Point> &Points, int npts, int i, int j, int k){
@ -3917,10 +3921,9 @@ inline void pmmc_CurveCurvature(DoubleArray &f, DoubleArray &s, DoubleArray &KN,
double &KNavg, double &KGavg, DTMutableList<Point> &Points, int npts, int ic, int jc, int kc){
int p,i,j,k;
double x,y,z,length;
double length;
double fxx,fyy,fzz,fxy,fxz,fyz,fx,fy,fz;
double sxx,syy,szz,sxy,sxz,syz,sx,sy,sz;
double Axx,Axy,Axz,Ayx,Ayy,Ayz,Azx,Azy,Azz;
// double Tx[8],Ty[8],Tz[8]; // Tangent vector
// double Nx[8],Ny[8],Nz[8]; // Principle normal
@ -4093,7 +4096,17 @@ inline void pmmc_CurveCurvature(DoubleArray &f, DoubleArray &s, DoubleArray &KN,
KGavg += K*(nwsx*nwnsx + nwsy*nwnsy + nwsz*nwnsz)*length;
}
}
NULL_USE(fxx); NULL_USE(fyy); NULL_USE(fzz);
NULL_USE(fxy); NULL_USE(fxz); NULL_USE(fyz);
NULL_USE(fx); NULL_USE(fy); NULL_USE(fz);
NULL_USE(sxx); NULL_USE(syy); NULL_USE(szz);
NULL_USE(sxy); NULL_USE(sxz); NULL_USE(syz);
NULL_USE(sx); NULL_USE(sy); NULL_USE(sz);
NULL_USE(Axx); NULL_USE(Ayy); NULL_USE(Azz);
NULL_USE(Axy); NULL_USE(Axz); NULL_USE(Ayz);
}
//--------------------------------------------------------------------------------------------------------
inline void pmmc_InterfaceSpeed(DoubleArray &dPdt, DoubleArray &P_x, DoubleArray &P_y, DoubleArray &P_z,
DoubleArray &CubeValues, DTMutableList<Point> &Points, IntArray &Triangles,

View File

@ -14,9 +14,8 @@ rm -rf CMake*
cmake \
-D CMAKE_C_COMPILER:PATH=cc \
-D CMAKE_CXX_COMPILER:PATH=CC \
-D CMAKE_CXX_COMPILER:PATH=CC \
-D CMAKE_C_FLAGS="-DCBUB" \
-D CMAKE_CXX_FLAGS="-DCBUB" \
-D CMAKE_CXX_FLAGS="-DCBUB -tp=bulldozer" \
-D MPI_COMPILER:BOOL=TRUE \
-D MPIEXEC=aprun \
-D USE_EXT_MPI_FOR_SERIAL_TESTS:BOOL=TRUE \
@ -28,11 +27,11 @@ cmake \
# Build the code
make install -j 8
# make install -j 8
# Run the fast tests
ctest -E WEEKLY
# ctest -E WEEKLY
# Run the slow tests

View File

@ -1,18 +1,31 @@
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/stat.h>
#include <math.h>
#include <stdexcept>
#include <vector>
#include <string>
#include <string.h>
#include <stdint.h>
#include "common/Utilities.h"
#include "common/UnitTest.h"
#include "common/MPI_Helpers.h"
// Detect the OS (defines which tests we allow to fail)
#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64) || defined(_MSC_VER)
#define USE_WINDOWS
#elif defined(__APPLE__)
#define USE_MAC
#elif defined(__linux) || defined(__unix) || defined(__posix)
#define USE_LINUX
#else
#error Unknown OS
#endif
// Function to return the call stack
std::vector<std::string> get_call_stack()
{
@ -32,73 +45,88 @@ int main(int argc, char *argv[])
UnitTest ut;
Utilities::setAbortBehavior( true, true, true );
// Test the memory usage
double t0 = Utilities::time();
size_t n_bytes1 = Utilities::getMemoryUsage();
double time1 = Utilities::time() - t0;
double *tmp = new double[0x100000];
NULL_USE(tmp);
t0 = Utilities::time();
size_t n_bytes2 = Utilities::getMemoryUsage();
double time2 = Utilities::time() - t0;
delete [] tmp;
t0 = Utilities::time();
size_t n_bytes3 = Utilities::getMemoryUsage();
double time3 = Utilities::time() - t0;
std::cout << "Number of bytes used for a basic test: " << n_bytes1 << ", " << n_bytes2 << ", " << n_bytes3 << std::endl;
std::cout << " Time to query: " << time1*1e6 << " us, " << time2*1e6 << " us, " << time3*1e6 << " us" << std::endl;
if ( n_bytes1==0 ) {
ut.failure("getMemoryUsage returns 0");
} else {
ut.passes("getMemoryUsage returns non-zero");
if ( n_bytes2>n_bytes1 )
ut.passes("getMemoryUsage increases size");
else
ut.failure("getMemoryUsage increases size");
if ( n_bytes1==n_bytes3 )
ut.passes("getMemoryUsage decreases size properly");
else
ut.expected_failure("getMemoryUsage does not decrease size properly");
}
// Limit the scope of variables
{
// Test the memory usage
double t0 = Utilities::time();
size_t n_bytes1 = Utilities::getMemoryUsage();
double time1 = Utilities::time() - t0;
uint64_t *tmp = new uint64_t[0x100000];
memset(tmp,0xAA,0x100000*sizeof(uint64_t));
NULL_USE(tmp);
t0 = Utilities::time();
size_t n_bytes2 = Utilities::getMemoryUsage();
double time2 = Utilities::time() - t0;
delete [] tmp;
t0 = Utilities::time();
size_t n_bytes3 = Utilities::getMemoryUsage();
double time3 = Utilities::time() - t0;
std::cout << "Number of bytes used for a basic test: " << n_bytes1 << ", " << n_bytes2 << ", " << n_bytes3 << std::endl;
std::cout << " Time to query: " << time1*1e6 << " us, " << time2*1e6 << " us, " << time3*1e6 << " us" << std::endl;
if ( n_bytes1==0 ) {
ut.failure("getMemoryUsage returns 0");
} else {
ut.passes("getMemoryUsage returns non-zero");
if ( n_bytes2>n_bytes1 ) {
ut.passes("getMemoryUsage increases size");
} else {
#if defined(USE_MAC)
ut.expected_failure("getMemoryUsage does not increase size");
#else
ut.failure("getMemoryUsage increases size");
#endif
}
if ( n_bytes1==n_bytes3 ) {
ut.passes("getMemoryUsage decreases size properly");
} else {
#if defined(USE_MAC) || defined(USE_WINDOWS)
ut.expected_failure("getMemoryUsage does not decrease size properly");
#else
ut.failure("getMemoryUsage does not decrease size properly");
#endif
}
}
// Test getting the current call stack
std::vector<std::string> call_stack = get_call_stack();
if ( rank==0 ) {
std::cout << "Call stack:" << std::endl;
for (size_t i=0; i<call_stack.size(); i++)
std::cout << " " << call_stack[i] << std::endl;
}
if ( !call_stack.empty() ) {
ut.passes("non empty call stack");
if ( call_stack[0].find("get_call_stack()") != std::string::npos )
ut.passes("call stack decoded function symbols");
// Test getting the current call stack
std::vector<std::string> call_stack = get_call_stack();
if ( rank==0 ) {
std::cout << "Call stack:" << std::endl;
for (size_t i=0; i<call_stack.size(); i++)
std::cout << " " << call_stack[i] << std::endl;
}
if ( !call_stack.empty() ) {
ut.passes("non empty call stack");
if ( call_stack[0].find("get_call_stack()") != std::string::npos )
ut.passes("call stack decoded function symbols");
else
ut.expected_failure("call stack was unable to decode function symbols");
} else {
ut.failure("non empty call stack");
}
// Test catching an error
try {
ERROR("Test");
ut.failure("Failed to catch RAY_ERROR");
} catch (...) {
ut.passes("Caught RAY_ERROR");
}
try {
throw std::logic_error("test");
ut.failure("Failed to catch exception");
} catch (...) {
ut.passes("Caught exception");
}
// Test time/tick
double time = Utilities::time();
double res = Utilities::tick();
if ( time==0 || res==0 )
ut.failure("time/tick");
else
ut.expected_failure("call stack was unable to decode function symbols");
} else {
ut.failure("non empty call stack");
}
ut.passes("time/tick");
// Test catching an error
try {
ERROR("Test");
ut.failure("Failed to catch RAY_ERROR");
} catch (...) {
ut.passes("Caught RAY_ERROR");
}
try {
throw std::logic_error("test");
ut.failure("Failed to catch exception");
} catch (...) {
ut.passes("Caught exception");
}
// Test time/tick
double time = Utilities::time();
double res = Utilities::tick();
if ( time==0 || res==0 )
ut.failure("time/tick");
else
ut.passes("time/tick");
// Finished
ut.report();