Skip to content

Commit

Permalink
Merge pull request #3 from ogmacorp/master
Browse files Browse the repository at this point in the history
Updating master
  • Loading branch information
rcrowder authored Nov 25, 2016
2 parents 4abb2a1 + 5e75e0f commit 05046a6
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 36 deletions.
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
1.1.1 November 25, 2016
=======================

- Release fixes
- Option to choose an OpenCL device
- Install and uninstall CMake changes

1.1 November, 2016
===================

Expand Down
38 changes: 25 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,21 @@ cmake_minimum_required(VERSION 3.1)

project(OgmaNeo)
set(CMAKE_VERBOSE_MAKEFILE OFF)

set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake")

#if(NOT CMAKE_BUILD_TYPE)
# message(STATUS "CMAKE_BUILD_TYPE not set, setting it to Release")
# set(CMAKE_BUILD_TYPE Release)
#endif()
#message("Build type: ${CMAKE_BUILD_TYPE}")
if(NOT CMAKE_BUILD_TYPE)
message("CMAKE_BUILD_TYPE not set, setting it to Release")
set(CMAKE_BUILD_TYPE Release)
endif()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")

if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(BITNESS 64)
set(BITNESS 64)
else()
set(BITNESS 32)
set(BITNESS 32)
endif()
#message("Bitness: ${BITNESS}")
message(STATUS "Bitness: ${BITNESS}")

option(BUILD_SHARED_LIBS OFF)
message(STATUS "Shared libs: ${BUILD_SHARED_LIBS}")
Expand Down Expand Up @@ -235,8 +236,10 @@ add_custom_target(OgmaOCLtoH ALL DEPENDS ${outFiles})

# Find list of library source code
file(GLOB_RECURSE LIBRARY_SRC
"source/*.h"
"source/*.cpp"
"source/neo/*.h"
"source/neo/*.cpp"
"source/system/*.h"
"source/system/*.cpp"
)

include_directories(SYSTEM "${PROJECT_SOURCE_DIR}/source")
Expand Down Expand Up @@ -265,9 +268,18 @@ endif()
# and OpenCL to H file generation
add_dependencies(OgmaNeo OgmaNeoSchemas OgmaOCLtoH)
target_link_libraries(OgmaNeo ${OPENCL_LIBRARIES})

set_property(TARGET OgmaNeo PROPERTY CXX_STANDARD 14)
set_property(TARGET OgmaNeo PROPERTY CXX_STANDARD_REQUIRED ON)

if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
if(BITNESS EQUAL 32)
set_target_properties(OgmaNeo PROPERTIES COMPILE_FLAGS "-m32" LINK_FLAGS "-m32")
else()
set_target_properties(OgmaNeo PROPERTIES COMPILE_FLAGS "-m64" LINK_FLAGS "-m64")
endif()
endif()

# Library install target
install(TARGETS OgmaNeo
RUNTIME DESTINATION bin
Expand All @@ -276,12 +288,12 @@ install(TARGETS OgmaNeo

# Headers, incl. schema headers, install targets
install(DIRECTORY "${PROJECT_SOURCE_DIR}/source/"
DESTINATION include
DESTINATION include/ogmaneo
FILES_MATCHING PATTERN "*.h*")

# 3rd party headers install targets
install(DIRECTORY "${3RDPARTY_PATH}/include/"
DESTINATION include
DESTINATION include/ogmaneo
FILES_MATCHING PATTERN "*.h*")

# Uninstall target
Expand All @@ -290,5 +302,5 @@ configure_file(
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)

add_custom_target(UNINSTALL
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

## Introduction

Welcome to [Ogma Intelligent Systems Corp](https://ogmacorp.com) OgmaNeo library. A C++ library that contains implementation(s) of Online Predictive Hierarchies, as described in the arXiv.org paper: [Feynman Machine: The Universal Dynamical Systems Computer](http://arxiv.org/abs/1609.03971).
Welcome to [Ogma](https://ogmacorp.com) OgmaNeo library. A C++ library that contains implementation(s) of Online Predictive Hierarchies, as described in the arXiv.org paper: [Feynman Machine: The Universal Dynamical Systems Computer](http://arxiv.org/abs/1609.03971).

The current release of this library contains a form of Sparse Predictive Hierarchies. Refer to the arXiv.org paper for further details.

Expand Down Expand Up @@ -232,7 +232,7 @@ Refer to the [CONTRIBUTING.md](https://github.com/ogmacorp/OgmaNeo/blob/master/C

<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png" /></a><br />The work in this repository is licensed under the <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>. See the [OGMANEO_LICENSE.md](https://github.com/ogmacorp/OgmaNeo/blob/master/OGMANEO_LICENSE.md) and [LICENSE.md](https://github.com/ogmacorp/OgmaNeo/blob/master/LICENSE.md) file for further information.

Contact Ogma Intelligent Systems Corp [email protected] to discuss commercial use and licensing options.
Contact Ogma via [email protected] to discuss commercial use and licensing options.

The OgmaNeo library uses the Google [FlatBuffers](http://google.github.io/flatbuffers/) package that is licensed with an Apache License (Version 2.0). Refer to this [LICENSE.txt](https://github.com/google/flatbuffers/blob/master/LICENSE.txt) file for the full licensing text associated with the FlatBuffers package.

Expand Down
12 changes: 6 additions & 6 deletions source/neo/Architect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,22 +245,22 @@ std::shared_ptr<class Agent> Architect::generateAgent(std::unordered_map<std::st

for (int i = 0; i < _actionLayers.size(); i++) {
if (_actionLayers[i]._params.find("a_radius") != _actionLayers[i]._params.end())
aLayerDescs[l][i]._radius = std::stoi(_actionLayers[l]._params["a_radius"]);
aLayerDescs[l][i]._radius = std::stoi(_actionLayers[i]._params["a_radius"]);

if (_actionLayers[i]._params.find("a_qAlpha") != _actionLayers[i]._params.end())
aLayerDescs[l][i]._qAlpha = std::stof(_actionLayers[l]._params["a_qAlpha"]);
aLayerDescs[l][i]._qAlpha = std::stof(_actionLayers[i]._params["a_qAlpha"]);

if (_actionLayers[i]._params.find("a_actionAlpha") != _actionLayers[i]._params.end())
aLayerDescs[l][i]._actionAlpha = std::stof(_actionLayers[l]._params["a_actionAlpha"]);
aLayerDescs[l][i]._actionAlpha = std::stof(_actionLayers[i]._params["a_actionAlpha"]);

if (_actionLayers[i]._params.find("a_qGamma") != _actionLayers[i]._params.end())
aLayerDescs[l][i]._qGamma = std::stof(_actionLayers[l]._params["a_qGamma"]);
aLayerDescs[l][i]._qGamma = std::stof(_actionLayers[i]._params["a_qGamma"]);

if (_actionLayers[i]._params.find("a_qLambda") != _actionLayers[i]._params.end())
aLayerDescs[l][i]._qLambda = std::stof(_actionLayers[l]._params["a_qLambda"]);
aLayerDescs[l][i]._qLambda = std::stof(_actionLayers[i]._params["a_qLambda"]);

if (_actionLayers[i]._params.find("a_actionLambda") != _actionLayers[i]._params.end())
aLayerDescs[l][i]._actionLambda = std::stof(_actionLayers[l]._params["a_actionLambda"]);
aLayerDescs[l][i]._actionLambda = std::stof(_actionLayers[i]._params["a_actionLambda"]);
}
}
else {
Expand Down
8 changes: 4 additions & 4 deletions source/neo/Architect.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ namespace ogmaneo {
Resources()
{}

Resources(ComputeSystem::DeviceType type) {
create(type);
Resources(ComputeSystem::DeviceType type, unsigned int index = 0) {
create(type, index);
}

void create(ComputeSystem::DeviceType type) {
void create(ComputeSystem::DeviceType type, unsigned int index = 0) {
_cs = std::make_shared<ComputeSystem>();
_cs->create(type);
_cs->create(type, index);
}

const std::shared_ptr<ComputeSystem> &getComputeSystem() const {
Expand Down
8 changes: 4 additions & 4 deletions source/neo/SparseFeaturesChunk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ void SparseFeaturesChunk::activate(ComputeSystem &cs, const std::vector<cl::Imag

// Inhibit
{
int chunksInX = _hiddenSize.x / _chunkSize.x + 1;
int chunksInY = _hiddenSize.y / _chunkSize.y + 1;
int chunksInX = static_cast<int>(std::ceil(static_cast<float>(_hiddenSize.x) / static_cast<float>(_chunkSize.x)));
int chunksInY = static_cast<int>(std::ceil(static_cast<float>(_hiddenSize.y) / static_cast<float>(_chunkSize.y)));

int argIndex = 0;

Expand Down Expand Up @@ -287,8 +287,8 @@ void SparseFeaturesChunk::learn(ComputeSystem &cs, std::mt19937 &rng) {
void SparseFeaturesChunk::inhibit(ComputeSystem &cs, const cl::Image2D &activations, cl::Image2D &states, std::mt19937 &rng) {
// Inhibit
{
int chunksInX = _hiddenSize.x / _chunkSize.x + 1;
int chunksInY = _hiddenSize.y / _chunkSize.y + 1;
int chunksInX = static_cast<int>(std::ceil(static_cast<float>(_hiddenSize.x) / static_cast<float>(_chunkSize.x)));
int chunksInY = static_cast<int>(std::ceil(static_cast<float>(_hiddenSize.y) / static_cast<float>(_chunkSize.y)));

int argIndex = 0;

Expand Down
16 changes: 11 additions & 5 deletions source/system/ComputeSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

using namespace ogmaneo;

bool ComputeSystem::create(DeviceType type, bool createFromGLContext) {
bool ComputeSystem::create(DeviceType type, unsigned int index, bool createFromGLContext) {
std::vector<cl::Platform> allPlatforms;
cl::Platform::get(&allPlatforms);

Expand Down Expand Up @@ -47,7 +47,13 @@ bool ComputeSystem::create(DeviceType type, bool createFromGLContext) {
}

if (!allDevices.empty()) {
_device = allDevices.front();
if (index >= allDevices.size()) {
#ifdef SYS_DEBUG
std::cout << "Indexed device not found." << std::endl;
#endif
return false;
}
_device = allDevices[index];

std::vector<size_t> workItemSizes;
_device.getInfo(CL_DEVICE_MAX_WORK_ITEM_SIZES, &workItemSizes);
Expand All @@ -73,14 +79,14 @@ bool ComputeSystem::create(DeviceType type, bool createFromGLContext) {
}
}

if (allDevices.empty()) {
if (allDevices.empty() || index >= allDevices.size()) {
#ifdef SYS_DEBUG
std::cout << "No devices found. Check your OpenCL installation." << std::endl;
#endif
return false;
}

_device = allDevices.front();
_device = allDevices[index];

#ifdef SYS_DEBUG
std::cout << "Using device: " << _device.getInfo<CL_DEVICE_NAME>() << std::endl;
Expand Down Expand Up @@ -122,4 +128,4 @@ bool ComputeSystem::create(DeviceType type, bool createFromGLContext) {
_queue = cl::CommandQueue(_context, _device);

return true;
}
}
4 changes: 2 additions & 2 deletions source/system/ComputeSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ namespace ogmaneo {
public:
/*!
\brief Create an OpenCL compute system with a given device type.
Optional: Create from an OpenGL context
Optional: Create from a device index and an OpenGL context
*/
bool create(DeviceType type, bool createFromGLContext = false);
bool create(DeviceType type, unsigned int index = 0, bool createFromGLContext = false);

/*!
\brief Get underlying OpenCL platform
Expand Down

0 comments on commit 05046a6

Please sign in to comment.