Skip to content

Commit

Permalink
Supporting osx
Browse files Browse the repository at this point in the history
  • Loading branch information
AngLi-Leon authored and apavlo committed Jul 13, 2017
1 parent 05fa4e1 commit 94f026a
Show file tree
Hide file tree
Showing 111 changed files with 573 additions and 302 deletions.
48 changes: 34 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
sudo: required
dist: trusty
#language: c++
matrix:
include:
- compiler: gcc
# Mac build
- os: osx
osx_image: xcode8.3
compiler: clang
env:
- PELOTON_BUILD_TYPE=Debug COVERALLS=Off

# Linux builds
- os: linux
sudo: required
dist: trusty
compiler: gcc
addons:
apt:
sources:
Expand All @@ -14,7 +23,11 @@ matrix:
- g++-4.9
env:
- CXX=g++-4.9 PELOTON_BUILD_TYPE=Debug COVERALLS=Off
- compiler: gcc

- os: linux
sudo: required
dist: trusty
compiler: gcc
addons:
apt:
sources:
Expand All @@ -27,7 +40,10 @@ matrix:
- CXX=g++-4.9 PELOTON_BUILD_TYPE=Release COVERALLS=Off

#Job where coveralls is executed
- compiler: gcc
- os: linux
sudo: required
dist: trusty
compiler: gcc
addons:
apt:
sources:
Expand All @@ -38,8 +54,11 @@ matrix:
- g++-5
env:
- CXX=g++-5 PELOTON_BUILD_TYPE=Debug COVERALLS=On

- compiler: gcc

- os: linux
sudo: required
dist: trusty
compiler: gcc
addons:
apt:
sources:
Expand All @@ -50,11 +69,11 @@ matrix:
- g++-5
env:
- CXX=g++-5 PELOTON_BUILD_TYPE=Release COVERALLS=Off

before_script:
# setup environment
- ./script/installation/packages.sh
- pip install --user cpp-coveralls
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then pip install --user cpp-coveralls; fi

script:
# first, run source_validator
Expand All @@ -63,19 +82,20 @@ script:
- mkdir build
- cd build
# run cmake
- cmake -DCOVERALLS=$COVERALLS -DCMAKE_BUILD_TYPE=$PELOTON_BUILD_TYPE -DUSE_SANITIZER=Address ..
- cmake -DCOVERALLS=$COVERALLS -DCMAKE_PREFIX_PATH=`llvm-config-3.7 --prefix` -DCMAKE_BUILD_TYPE=$PELOTON_BUILD_TYPE -DUSE_SANITIZER=Address ..
# build
- make -j4
# run tests
- make check -j4
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then make check -j4; fi
- if [[ $TRAVIS_OS_NAME == 'osx' ]]; then ASAN_OPTIONS=detect_container_overflow=0 make check -j4; fi
# build benchmarks
- make benchmark -j4
# install peloton
- make install
# run psql tests
- bash ../script/testing/psql/psql_test.sh
- bash ../script/testing/psql/psql_test.sh $TRAVIS_OS_NAME
# run jdbc tests
- python ../script/validators/jdbc_validator.py
- python ../script/validators/jdbc_validator.py $TRAVIS_OS_NAME
# upload coverage info
- bash -c "if [ \"${COVERALLS^^}\" = 'ON' ] ; then make coveralls; fi"
- bash -c "if [ $(echo $COVERALLS | tr "[:lower:]" "[:upper:]") = 'ON' ] ; then echo 1; fi"

5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -ggdb -fno-omit-frame-po

# ---[ Flags
if(UNIX OR APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall -Wextra -Werror -mcx16 -Wno-invalid-offsetof -march=native")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall -Wextra -Werror -mcx16 -Wno-invalid-offsetof -march=native")
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-tautological-undefined-compare -Wno-unused-private-field -Wno-braced-scalar-init -Wno-constant-conversion -Wno-potentially-evaluated-expression -Wno-infinite-recursion -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -I/usr/local/opt/openssl/include")
endif()
endif()

# ---[ Warnings
Expand Down
29 changes: 27 additions & 2 deletions script/installation/packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fi
# For everything else (or if above failed), just use generic identifier
[ "$DISTRO" == "" ] && export DISTRO=$UNAME
unset UNAME
DISTRO=${DISTRO^^}
DISTRO=$(echo $DISTRO | tr "[:lower:]" "[:upper:]")
TMPDIR=/tmp

function install_repo_package() {
Expand Down Expand Up @@ -156,7 +156,32 @@ elif [[ "$DISTRO" == *"REDHAT"* ]] && [[ "${DISTRO_VER%.*}" == "7" ]]; then
for pkg_path in ${PKGS[@]}; do
install_package $pkg_path
done


## ------------------------------------------------
## DARWIN (OSX)
## ------------------------------------------------
elif [ "$DISTRO" = "DARWIN" ]; then
if test ! $(which brew); then
echo "Installing homebrew..."
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi

brew install git
brew install cmake
brew install gflags
brew install protobuf
brew install bison
brew install flex
brew install libevent
brew install boost
brew install jemalloc
brew install valgrind
brew install lcov
brew install libpqxx
brew install libedit
brew install llvm@3.7
brew install postgresql

## ------------------------------------------------
## UNKNOWN
## ------------------------------------------------
Expand Down
7 changes: 6 additions & 1 deletion script/testing/psql/psql_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# NOTE: absolute path to peloton directory is calculated from current directory
# directory structure: peloton/scripts/testing/psql/<this_file>
CODE_SOURCE_DIR=`dirname $0`
OS_NAME=$1
REF_OUT_FILE="$CODE_SOURCE_DIR/psql_ref_out.txt"
TEMP_OUT_FILE="/tmp/psql_out-$$"

Expand Down Expand Up @@ -51,7 +52,11 @@ trap cleanup EXIT
cd $PELOTON_DIR/build

# start peloton
bin/peloton -port $PELOTON_PORT > /dev/null &
if [ "$OS_NAME" == "osx" ]; then
ASAN_OPTIONS=detect_container_overflow=0 bin/peloton -port $PELOTON_PORT > /dev/null &
else
bin/peloton -port $PELOTON_PORT > /dev/null &
fi
PELOTON_PID=$!
sleep 3

Expand Down
12 changes: 7 additions & 5 deletions script/validators/jdbc_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@
EXIT_SUCCESS = 0
EXIT_FAILURE = -1

def runTest(script, enableStats=False):
def runTest(script, enableStats=False, isOSX=False):
# Launch Peloton
args = "-port " + str(PELOTON_PORT)
if enableStats:
args += " -stats_mode 1"
cmd = ['exec ' + PELOTON_BIN + ' ' + args]
if isOSX:
cmd = ['ASAN_OPTIONS=detect_container_overflow=0 exec ' + PELOTON_BIN + ' ' + args]
else:
cmd = ['exec ' + PELOTON_BIN + ' ' + args]
peloton = subprocess.Popen(cmd, shell=True)
time.sleep(3) # HACK

Expand All @@ -54,16 +57,15 @@ def runTest(script, enableStats=False):


if __name__ == '__main__':

if not os.path.exists(PELOTON_BIN):
raise Exception("Unable to find Peloton binary '%s'" % PELOTON_BIN)
if not os.path.exists(PELOTON_JDBC_SCRIPT_DIR):
raise Exception("Unable to find JDBC script dir '%s'" % PELOTON_JDBC_SCRIPT_DIR)

## Basic
runTest("test_jdbc.sh")
runTest("test_jdbc.sh", isOSX=sys.argv[1] == 'osx')

## Stats
# runTest("test_jdbc.sh", enableStats=True)
# runTest("test_jdbc.sh", enableStats=True, sys.argv[1] == 'osx')

## MAIN
4 changes: 3 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ set(EXE_LINK_FLAGS "-Wl,--no-as-needed")
set(EXE_LIST peloton-bin ycsb tpcc sdbench tpch)
foreach(exe_name ${EXE_LIST})
target_link_libraries(${exe_name} ${EXE_LINK_LIBRARIES})
set_target_properties(${exe_name} PROPERTIES LINK_FLAGS ${EXE_LINK_FLAGS})
if (LINUX)
set_target_properties(${exe_name} PROPERTIES LINK_FLAGS ${EXE_LINK_FLAGS})
endif ()
endforeach()

# --[ benchmark
Expand Down
2 changes: 1 addition & 1 deletion src/catalog/column_stats_catalog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ std::unique_ptr<std::vector<type::Value>> ColumnStatsCatalog::GetColumnStats(
most_common_vals, most_common_freqs,
hist_bounds, column_name, has_index}));

return std::move(column_stats);
return column_stats;
}

// Return value: number of column stats
Expand Down
2 changes: 1 addition & 1 deletion src/codegen/oa_hash_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ std::pair<llvm::Value *, llvm::Value *> OAHashTable::GetDataCountAndPointer(
"singleValue"};
{
data_count_inline = codegen.Const64(1);
data_ptr_inline = AdvancePointer(codegen, after_key_p, 0UL);
data_ptr_inline = AdvancePointer(codegen, after_key_p, (uint64_t) 0UL);
}
is_entry_single_value.ElseBlock("multipleValue");
{
Expand Down
2 changes: 1 addition & 1 deletion src/codegen/proxy/data_table_proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const std::string& DataTableProxy::_GetTileGroupCount::GetFunctionName() {
// TODO: FIX ME
static const std::string kGetTileGroupCount =
#ifdef __APPLE__
"_ZNK7peloton7storage9DataTable17GetTileGroupCountEvy";
"_ZNK7peloton7storage9DataTable17GetTileGroupCountEv";
#else
"_ZNK7peloton7storage9DataTable17GetTileGroupCountEv";
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/codegen/proxy/oa_hash_table_proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ llvm::Type *OAHashTableProxy::GetType(CodeGen &codegen) {
const std::string &OAHashTableProxy::_Init::GetFunctionName() {
static const std::string kInitFnName =
#ifdef __APPLE__
"_ZN7peloton7codegen4util11OAHashTable4InitEmmm";
"_ZN7peloton7codegen4util11OAHashTable4InitEyyy";
#else
"_ZN7peloton7codegen4util11OAHashTable4InitEmmm";
#endif
Expand Down Expand Up @@ -142,7 +142,7 @@ llvm::Function *OAHashTableProxy::_Destroy::GetFunction(CodeGen &codegen) {
const std::string &OAHashTableProxy::_StoreTuple::GetFunctionName() {
static const std::string kStoreTupleFnName =
#ifdef __APPLE__
"_ZN7peloton7codegen4util11OAHashTable10StoreTupleEPNS2_9HashEntryEm";
"_ZN7peloton7codegen4util11OAHashTable10StoreTupleEPNS2_9HashEntryEy";
#else
"_ZN7peloton7codegen4util11OAHashTable10StoreTupleEPNS2_9HashEntryEm";
#endif
Expand Down
11 changes: 10 additions & 1 deletion src/codegen/proxy/values_runtime_proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,12 @@ llvm::Function *ValuesRuntimeProxy::_OutputInteger::GetFunction(

const std::string &ValuesRuntimeProxy::_OutputBigInt::GetFunctionName() {
static const std::string kOutputBigIntFnName =
#ifdef __APPLE__
"_ZN7peloton7codegen13ValuesRuntime12OutputBigIntEPcjx";
#else
"_ZN7peloton7codegen13ValuesRuntime12OutputBigIntEPcjl";
#endif

return kOutputBigIntFnName;
}

Expand Down Expand Up @@ -221,7 +226,11 @@ llvm::Function *ValuesRuntimeProxy::_OutputDate::GetFunction(CodeGen &codegen) {

const std::string &ValuesRuntimeProxy::_OutputTimestamp::GetFunctionName() {
static const std::string kOutputTimestampFnName =
#ifdef __APPLE__
"_ZN7peloton7codegen13ValuesRuntime15OutputTimestampEPcjx";
#else
"_ZN7peloton7codegen13ValuesRuntime15OutputTimestampEPcjl";
#endif
return kOutputTimestampFnName;
}

Expand Down Expand Up @@ -250,7 +259,7 @@ llvm::Function *ValuesRuntimeProxy::_OutputTimestamp::GetFunction(
const std::string &ValuesRuntimeProxy::_OutputVarchar::GetFunctionName() {
static const std::string kOutputVarcharFnName =
#ifdef __APPLE__
"_ZN7peloton7codegen13ValuesRuntime13outputVarcharEPcjS2_j";
"_ZN7peloton7codegen13ValuesRuntime13OutputVarcharEPcjS2_j";
#else
"_ZN7peloton7codegen13ValuesRuntime13OutputVarcharEPcjS2_j";
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/codegen/tile_group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ codegen::Value TileGroup::LoadColumn(
sql_type.GetTypeForMaterialization(codegen, col_type, col_len_type);
PL_ASSERT(col_type != nullptr && col_len_type == nullptr);

val = codegen->CreateLoad(col_type, col_address);
val = codegen->CreateLoad(col_type, codegen->CreateBitCast(col_address, col_type->getPointerTo()));

if (is_nullable) {
// To check for NULL, we need to perform a comparison between the value we
Expand Down
4 changes: 2 additions & 2 deletions src/codegen/util/cc_hash_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ char* CCHashTable::StoreTuple(uint64_t hash, uint32_t size) {
// Clean up any resources this hash table has
//===----------------------------------------------------------------------===//
void CCHashTable::Destroy() {
LOG_DEBUG("Cleaning up hash table with %ld entries ...", num_elements_);
LOG_DEBUG("Cleaning up hash table with %llu entries ...", (unsigned long long) num_elements_);
for (uint64_t i = 0; i < num_buckets_; i++) {
uint32_t chain_length = 0;
HashEntry* e = buckets_[i];
Expand All @@ -90,7 +90,7 @@ void CCHashTable::Destroy() {
chain_length++;
}
if (chain_length > kMaxHashChainSize) {
LOG_DEBUG("Bucket %ld chain length = %u ...", i, chain_length);
LOG_DEBUG("Bucket %llu chain length = %u ...", (unsigned long long) i, chain_length);
}
}
free(buckets_);
Expand Down
6 changes: 3 additions & 3 deletions src/codegen/util/oa_hash_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ void OAHashTable::Resize(HashEntry **entry_p_p) {
// Make it an assertion to prevent potential bugs
PL_ASSERT(NeedsResize());

LOG_DEBUG("Resizing hash-table from %lu buckets to %lu", num_buckets_,
num_buckets_ << 1);
LOG_DEBUG("Resizing hash-table from %llu buckets to %llu", (unsigned long long) num_buckets_,
(unsigned long long) num_buckets_ << 1);

// Double the size of the array
num_buckets_ <<= 1;
Expand Down Expand Up @@ -364,7 +364,7 @@ void OAHashTable::Resize(HashEntry **entry_p_p) {
// them, and then delete the entire array.
//===----------------------------------------------------------------------===//
void OAHashTable::Destroy() {
LOG_DEBUG("Cleaning up hash table with %ld entries ...", num_entries_);
LOG_DEBUG("Cleaning up hash table with %llu entries ...", (unsigned long long) num_entries_);

uint64_t processed_count = 0;
char *current_entry_char_p = reinterpret_cast<char *>(buckets_);
Expand Down
12 changes: 6 additions & 6 deletions src/codegen/util/sorter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ void Sorter::Init(ComparisonFunction func, uint32_t tuple_size) {
buffer_pos_ = buffer_start_;
buffer_end_ = buffer_start_ + kInitialBufferSize;

LOG_INFO("Initialized Sorter with size %lu KB for tuples of size %u...",
kInitialBufferSize / 1024, tuple_size_);
LOG_INFO("Initialized Sorter with size %llu KB for tuples of size %u...",
(unsigned long long) kInitialBufferSize / 1024, tuple_size_);
}

// StoreValue a tuple of the given size in this sorter. We return a buffer that
Expand Down Expand Up @@ -78,13 +78,13 @@ void Sorter::Sort() {

uint64_t num_tuples = GetNumTuples();

LOG_DEBUG("Going to sort %lu tuples in sort buffer", num_tuples);
LOG_DEBUG("Going to sort %llu tuples in sort buffer", (unsigned long long) num_tuples);

// Sort the sucker
std::qsort(buffer_start_, num_tuples, tuple_size_, cmp_func_);

timer.Stop();
LOG_INFO("Sorted %lu tuples in %.2f ms", num_tuples, timer.GetDuration());
LOG_INFO("Sorted %llu tuples in %.2f ms", (unsigned long long) num_tuples, timer.GetDuration());
}

// Release any memory we allocated from the storage manager.
Expand Down Expand Up @@ -112,8 +112,8 @@ void Sorter::Resize() {

// Allocate double the buffer room
uint64_t next_alloc_size = curr_alloc_size << 1;
LOG_DEBUG("Resizing sorter from %lu bytes to %lu bytes ...", curr_alloc_size,
next_alloc_size);
LOG_DEBUG("Resizing sorter from %llu bytes to %llu bytes ...", (unsigned long long) curr_alloc_size,
(unsigned long long) next_alloc_size);

auto &backend_manager = storage::BackendManager::GetInstance();

Expand Down
Loading

0 comments on commit 94f026a

Please sign in to comment.