Skip to content

Commit

Permalink
BAAR ADAPT'15
Browse files Browse the repository at this point in the history
  • Loading branch information
Marvin Damschen committed Nov 24, 2014
1 parent c91fb01 commit 7a2262a
Show file tree
Hide file tree
Showing 55 changed files with 14,899 additions and 1 deletion.
31 changes: 31 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
cmake_minimum_required(VERSION 2.8)

project(BAAR)

if(NOT LLVM_SRC_DIR)
message(FATAL_ERROR "LLVM_SRC_DIR undefined, please define it to point to LLVM source")
endif()

if(NOT LLVM_BIN_DIR)
message(FATAL_ERROR "LLVM_BIN_DIR undefined, please define it to point to the LLVM build corresponding to the sources in LLVM_SRC_DIR")
endif()

set(CMAKE_BUILD_TYPE Debug)
add_definitions(-D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_FORMAT_MACROS)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-rtti")

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out/bin)

link_directories(${LLVM_BIN_DIR}/lib)
include_directories(${LLVM_SRC_DIR}/include ${LLVM_BIN_DIR}/include)

find_package(Threads REQUIRED)
find_package(OpenMP)
find_package(Curses)

add_subdirectory(common)
add_subdirectory(client)
add_subdirectory(server)
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
baar
BAAR
====

Binary Acceleration at Runtime

### Building with CMake

First, LLVM has to be built from source with CMake (See: [Building LLVM with CMake](http://llvm.org/docs/CMake.html)). Afterwards, checkout this repository into another directory and run the following statements:

$ cmake -DLLVM_SRC_DIR=/path/to/llvm-3.4/source -DLLVM_BIN_DIR=/path/to/llvm-3.4/build .
$ make

This should do the trick or help you out with telling you which libraries are missing, if any. All binaries are generated in the `out` directory.
57 changes: 57 additions & 0 deletions client/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
add_subdirectory(pass)

add_executable(baar_client abstractclient.cpp shmemclient.cpp socketclient.cpp main.cpp)

target_link_libraries(baar_client baar_common baar_client_passes)

find_library(LLVMX86_FOUND LLVMX86Utils PATHS ${LLVM_BIN_DIR}/lib)
if(LLVMX86_FOUND)
target_link_libraries(baar_client
LLVMX86Disassembler
LLVMX86AsmParser
LLVMX86CodeGen
LLVMX86Desc
LLVMX86Info
LLVMX86AsmPrinter
LLVMX86Utils
)
endif()

target_link_libraries(baar_client
LLVMPolly
LLVMIRReader
LLVMBitReader
LLVMBitWriter
LLVMAsmParser
LLVMSelectionDAG
LLVMAsmPrinter
LLVMMCParser
LLVMJIT
LLVMRuntimeDyld
LLVMExecutionEngine
LLVMCodeGen
LLVMipo
LLVMVectorize
LLVMObjCARCOpts
LLVMScalarOpts
LLVMInstCombine
LLVMInstrumentation
LLVMTransformUtils
LLVMipa
LLVMAnalysis
LLVMTarget
LLVMMC
LLVMObject
LLVMCore
LLVMSupport
)

target_link_libraries(baar_client ${CMAKE_DL_LIBS} ${CMAKE_THREAD_LIBS_INIT})

if(UNIX AND NOT APPLE)
target_link_libraries(baar_client rt)
endif()

if(CURSES_FOUND AND NOT ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "k1om")
target_link_libraries(baar_client ${CURSES_LIBRARIES})
endif()
46 changes: 46 additions & 0 deletions client/abstractclient.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright (c) 2014 Marvin Damschen (marvin.damschen@gullz.de)

// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:

// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#include "abstractclient.h"


long AbstractClient::getTimeDiffOpt() const
{
return TimeDiffOpt;
}

long AbstractClient::getTimeDiffInit() const
{
return TimeDiffInit;
}

long AbstractClient::getTimeDiffLastExecution() const
{
return TimeDiffLastExecution;
}

AbstractClient::AbstractClient()
{
}

AbstractClient::~AbstractClient()
{

}
50 changes: 50 additions & 0 deletions client/abstractclient.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright (c) 2014 Marvin Damschen (marvin.damschen@gullz.de)

// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:

// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#ifndef ABSTRACTCLIENT_H
#define ABSTRACTCLIENT_H

#include <string>
#include <cstdarg>
#include <chrono>

class AbstractClient
{
protected:
static void error(const char *msg) {
perror(msg);
exit(1);
}

long TimeDiffOpt = -1;
long TimeDiffInit = -1;
long TimeDiffLastExecution = -1;

public:
AbstractClient();
virtual ~AbstractClient();
virtual void initialiseAccelerationWithIR(const std::string &IR) = 0; // when function returns, server has to be ready to accept calls
virtual void callAcc(const char *retTypeFuncNameArgTypes, va_list args) = 0;
long getTimeDiffOpt() const;
long getTimeDiffInit() const;
long getTimeDiffLastExecution() const;
};

#endif // ABSTRACTCLIENT_H

0 comments on commit 7a2262a

Please sign in to comment.