Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
submodules: recursive
- name: Install Linux deps
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get -y --no-install-recommends install git g++ cmake ninja-build llvm-15-dev zlib1g-dev libglew-dev flex bison libfl-dev libzstd-dev
run: sudo apt-get update && sudo apt-get -y --no-install-recommends install git g++ cmake ninja-build llvm-15-dev zlib1g-dev flex bison libfl-dev libzstd-dev
- name: Install macOS deps
if: runner.os == 'macOS'
run: brew install cmake ninja llvm@15 zlib glew flex bison boost zstd ncurses
run: brew install cmake ninja llvm@15 zlib flex bison boost zstd ncurses
- uses: actions/checkout@v6
if: runner.os == 'Linux'
with:
Expand Down
16 changes: 13 additions & 3 deletions ocelot/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ option(BUILD_LLVM "Use LLVM compiled from sources: default OFF" OFF)
option(BUILD_TESTS "Build tests: default OFF" OFF)
option(BUILD_TESTS_CUDA "Build CUDA tests: default ON" ON)
option(BUILD_TOOLS "Build tool executables: default ON" ON)
option(ENABLE_OPENGL "Build OpenGL interop support" OFF)

if (NOT APPLE AND BUILD_TESTS AND BUILD_TESTS_CUDA)
project(gpuocelot C CXX CUDA ASM)
Expand Down Expand Up @@ -36,11 +37,14 @@ set(Boost_USE_MULTITHREADED ON)
find_package(Boost COMPONENTS filesystem thread REQUIRED)
find_package(FLEX 2.5 REQUIRED)
find_package(BISON 2.5 REQUIRED)
find_package(GLEW REQUIRED)
find_package(ZLIB REQUIRED)
find_library(ZSTD_LIB NAMES zstd libzstd)
find_package(Curses REQUIRED)

if (ENABLE_OPENGL)
find_package(GLEW REQUIRED)
endif()

if ("x${BUILD_LLVM}" STREQUAL "xOFF")
find_package(LLVM REQUIRED CONFIG)

Expand Down Expand Up @@ -239,20 +243,26 @@ separate_arguments(LLVM_DEFINITIONS_LIST NATIVE_COMMAND ${PROJECT_NAME}_DEFINITI

set(${PROJECT_NAME}_INCLUDE_DIRS
${LLVM_INCLUDE_DIRS}
${GLEW_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/cuda-fatbin-decompression
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_BINARY_DIR})

set(${PROJECT_NAME}_LINK_LIBRARIES
GLEW::GLEW
hydrazine
Boost::filesystem
ZLIB::ZLIB
${CURSES_LIBRARIES}
${ZSTD_LIB}
${CMAKE_DL_LIBS})

if (ENABLE_OPENGL)
list(APPEND ${PROJECT_NAME}_INCLUDE_DIRS ${GLEW_INCLUDE_DIRS})
list(APPEND ${PROJECT_NAME}_LINK_LIBRARIES GLEW::GLEW)
list(APPEND ${PROJECT_NAME}_DEFINITIONS ENABLE_OPENGL=1)
else()
list(APPEND ${PROJECT_NAME}_DEFINITIONS ENABLE_OPENGL=0)
endif()

if ("x${BUILD_LLVM}" STREQUAL "xON")
list(APPEND ${PROJECT_NAME}_LINK_LIBRARIES llvm)
endif()
Expand Down
10 changes: 9 additions & 1 deletion ocelot/ThirdParty/hydrazine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,22 @@ cmake_minimum_required(VERSION 2.8.12)
project(hydrazine CXX)

find_package(Boost COMPONENTS thread REQUIRED)
if (ENABLE_OPENGL)
find_package(OpenGL REQUIRED)
endif()

file(GLOB SRCS "src/*.cpp")
add_library(${PROJECT_NAME} STATIC ${SRCS})
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11)
set_property(TARGET ${PROJECT_NAME} PROPERTY POSITION_INDEPENDENT_CODE ON)
target_link_libraries(${PROJECT_NAME} Boost::thread OpenGL::GL)
target_link_libraries(${PROJECT_NAME} Boost::thread)
if (ENABLE_OPENGL)
target_link_libraries(${PROJECT_NAME} OpenGL::GL)
target_compile_definitions(${PROJECT_NAME} PRIVATE ENABLE_OPENGL=1)
else()
target_compile_definitions(${PROJECT_NAME} PRIVATE ENABLE_OPENGL=0)
endif()

include(CTest)

Expand Down
16 changes: 11 additions & 5 deletions ocelot/ThirdParty/hydrazine/src/SystemCompatibility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
#include <sys/types.h>
#include <sys/sysctl.h>
#elif __GNUC__
#if ENABLE_OPENGL
#include <GL/glx.h>
#endif
#include <unistd.h>
#include <sys/sysinfo.h>
#include <cxxabi.h>
Expand Down Expand Up @@ -75,12 +77,16 @@ namespace hydrazine

bool isAnOpenGLContextAvailable()
{
#if __APPLE__
// TODO fill this in
#if ENABLE_OPENGL
#if __APPLE__
// TODO fill this in
return false;
#elif __GNUC__
GLXContext openglContext = glXGetCurrentContext();
return (openglContext != 0);
#endif
#else
return false;
#elif __GNUC__
GLXContext openglContext = glXGetCurrentContext();
return (openglContext != 0);
#endif
}

Expand Down
4 changes: 4 additions & 0 deletions ocelot/include/ocelot/cuda/CudaDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@
#endif

// OpenGL Includes
#if ENABLE_OPENGL
#ifdef __APPLE__
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif
#else
typedef unsigned int GLuint;
#endif

// Standard Library Includes
#include <string>
Expand Down
4 changes: 4 additions & 0 deletions ocelot/include/ocelot/cuda/CudaDriverInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@
#undef min
#endif

#if ENABLE_OPENGL
#ifdef __APPLE__
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif
#else
typedef unsigned int GLuint;
#endif

// Ocelot includes
#include <ocelot/cuda/cuda_internal.h>
Expand Down
10 changes: 10 additions & 0 deletions ocelot/src/executive/EmulatorDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
#endif

// OpenGL includes
#if ENABLE_OPENGL
#include <GL/glew.h>
#endif

// Standard library includes
#include <cstring>
Expand Down Expand Up @@ -574,6 +576,7 @@ namespace executive
void EmulatorDevice::mapGraphicsResource(void** resource, int count,
unsigned int stream)
{
#if ENABLE_OPENGL
report("mapGraphicsResource(" << resource << ", "
<< count << ", " << stream << ")");

Expand Down Expand Up @@ -626,6 +629,9 @@ namespace executive
Throw("OpenGL Error in mapGraphicsResource() - glBindBuffer2.")
}
}
#else
Throw("OpenGL interop disabled.");
#endif
}

void* EmulatorDevice::getPointerToMappedGraphicsResource(size_t& size,
Expand Down Expand Up @@ -668,6 +674,7 @@ namespace executive
void EmulatorDevice::unmapGraphicsResource(void** resource, int count,
unsigned int streamID)
{
#if ENABLE_OPENGL
for (int i = 0; i < count; i++) {
unsigned int handle = hydrazine::bit_cast<unsigned int>(
resource[i]);
Expand Down Expand Up @@ -713,6 +720,9 @@ namespace executive
Throw("OpenGL Error in unmapGraphicsResource() - glBindBuffer.")
}
}
#else
Throw("OpenGL interop disabled.");
#endif
}

void EmulatorDevice::load(const ir::Module* module)
Expand Down
Loading