Skip to content

Commit

Permalink
Merge pull request #814 from arrayfire/hotfixes-3.0.1
Browse files Browse the repository at this point in the history
v3.0.1
  • Loading branch information
pavanky committed Jun 12, 2015
2 parents c047384 + 42eca27 commit 17db1c9
Show file tree
Hide file tree
Showing 69 changed files with 974 additions and 452 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Expand Up @@ -6,4 +6,4 @@
url = https://github.com/arrayfire/assets
[submodule "test/gtest"]
path = test/gtest
url = http://git.chromium.org/external/googletest.git
url = https://chromium.googlesource.com/external/googletest
12 changes: 6 additions & 6 deletions CMakeLists.txt
Expand Up @@ -16,9 +16,6 @@ OPTION(BUILD_GRAPHICS "Build ArrayFire with Forge Graphics" ON)
OPTION(BUILD_DOCS "Create ArrayFire Documentation" OFF)
OPTION(WITH_COVERAGE "Added code coverage flags" OFF)

OPTION(INSTALLER_MODE "Build arrayfire in installer mode" OFF)
MARK_AS_ADVANCED(INSTALLER_MODE)

# Set a default build type if none was specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
Expand Down Expand Up @@ -52,12 +49,11 @@ IF(BUILD_GRAPHICS)
IF(FORGE_FOUND)
ADD_DEFINITIONS(-DGLEW_MX -DWITH_GRAPHICS)
INCLUDE("${CMAKE_MODULE_PATH}/FindGLEWmx.cmake")
FIND_PACKAGE(GLFW)

INCLUDE_DIRECTORIES(
${FORGE_INCLUDE_DIRECTORIES}
${GLEW_INCLUDE_DIR}
${GLFW_INCLUDE_DIR})
)

SET(FORGE_LIBRARIES ${FORGE_LIBRARIES}
${GLEWmx_LIBRARY}
Expand Down Expand Up @@ -201,7 +197,11 @@ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/Install/ArrayFireConfig.cmake
DESTINATION ${AF_INSTALL_CMAKE_DIR}
COMPONENT cmake)

IF(APPLE)
INCLUDE("${CMAKE_MODULE_PATH}/osx_install/OSXInstaller.cmake")
ENDIF(APPLE)

##
# Packaging
##
include(${CMAKE_CURRENT_SOURCE_DIR}/CPack.txt)
include(${CMAKE_CURRENT_SOURCE_DIR}/CPack.cmake)
48 changes: 24 additions & 24 deletions CMakeModules/CUDACheckCompute.cmake
Expand Up @@ -5,34 +5,34 @@
# Check for GPUs present and their compute capability
# based on http://stackoverflow.com/questions/2285185/easiest-way-to-test-for-existence-of-cuda-capable-gpu-from-cmake/2297877#2297877 (Christopher Bruns)

if(CUDA_FOUND)
message(STATUS "${CMAKE_MODULE_PATH}/cuda_compute_capability.c")
try_run(RUN_RESULT_VAR COMPILE_RESULT_VAR
IF(CUDA_FOUND)
MESSAGE(STATUS "${CMAKE_MODULE_PATH}/cuda_compute_capability.cpp")

TRY_RUN(RUN_RESULT_VAR COMPILE_RESULT_VAR
${CMAKE_BINARY_DIR}
${CMAKE_MODULE_PATH}/cuda_compute_capability.c
${CMAKE_MODULE_PATH}/cuda_compute_capability.cpp
CMAKE_FLAGS
-DINCLUDE_DIRECTORIES:STRING=${CUDA_TOOLKIT_INCLUDE}
-DLINK_LIBRARIES:STRING=${CUDA_CUDART_LIBRARY}
COMPILE_OUTPUT_VARIABLE COMPILE_OUTPUT_VAR
RUN_OUTPUT_VARIABLE RUN_OUTPUT_VAR)
message(STATUS "Compile: ${RUN_OUTPUT_VAR}")
if (COMPILE_RESULT_VAR)
message(STATUS "compiled -> " ${RUN_RESULT_VAR})
else()
message(STATUS "didn't compile")
endif()

MESSAGE(STATUS "CUDA Compute Detection Output: ${RUN_OUTPUT_VAR}")
MESSAGE(STATUS "CUDA Compute Detection Return: ${RUN_RESULT_VAR}")

# COMPILE_RESULT_VAR is TRUE when compile succeeds
# RUN_RESULT_VAR is zero when a GPU is found
if(COMPILE_RESULT_VAR AND NOT RUN_RESULT_VAR)
message(STATUS "worked")
set(CUDA_HAVE_GPU TRUE CACHE BOOL "Whether CUDA-capable GPU is present")
set(CUDA_DETECTED_COMPUTE ${RUN_OUTPUT_VAR} CACHE STRING "Compute capability of CUDA-capable GPU present")
#set(CUDA_GENERATE_CODE "arch=compute_${CUDA_DETECTED_COMPUTE},code=sm_${CUDA_DETECTED_COMPUTE}" CACHE STRING "Which GPU architectures to generate code for (each arch/code pair will be passed as --generate-code option to nvcc, separate multiple pairs by ;)")
#mark_as_advanced(CUDA_DETECTED_COMPUTE CUDA_GENERATE_CODE)
#set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -arch compute_${CUDA_DETECTED_COMPUTE})
mark_as_advanced(CUDA_DETECTED_COMPUTE)
else()
message(STATUS "didn't work")
set(CUDA_HAVE_GPU FALSE CACHE BOOL "Whether CUDA-capable GPU is present")
endif()
endif()
# Check Return Value of main() from RUN_RESULT_VAR
# RUN_RESULT_VAR is 0 when a GPU is found
# RUN_RESULT_VAR is 1 when errors occur

IF(COMPILE_RESULT_VAR AND RUN_RESULT_VAR EQUAL 0)
MESSAGE(STATUS "CUDA Compute Detection Worked")
# Convert output into a list of computes
STRING(REPLACE " " ";" COMPUTES_DETECTED_LIST ${RUN_OUTPUT_VAR})
SET(CUDA_HAVE_GPU TRUE CACHE BOOL "Whether CUDA-capable GPU is present")
ELSE()
MESSAGE(STATUS "CUDA Compute Detection Failed")
SET(CUDA_HAVE_GPU FALSE CACHE BOOL "Whether CUDA-capable GPU is present")
ENDIF()

ENDIF(CUDA_FOUND)
15 changes: 6 additions & 9 deletions CMakeModules/FindForge.cmake
Expand Up @@ -74,15 +74,14 @@ FIND_LIBRARY(FORGE_LIBRARY
HINTS "${FORGE_PACKAGE_DIR}/lib")

INCLUDE("${CMAKE_MODULE_PATH}/FindGLEWmx.cmake")
INCLUDE("${CMAKE_MODULE_PATH}/FindGLFW.cmake")

IF(GLFW_FOUND AND GLEWmx_FOUND AND OPENGL_FOUND)
IF(GLEWmx_FOUND AND OPENGL_FOUND)
IF(FORGE_INCLUDE_DIRECTORIES)
SET(FORGE_INCLUDE_DIRECTORIES ${FORGE_INCLUDE_DIRECTORIES} ${GLFW_INCLUDE_DIR} ${GLEW_INCLUDE_DIR}
SET(FORGE_INCLUDE_DIRECTORIES ${FORGE_INCLUDE_DIRECTORIES} ${GLEW_INCLUDE_DIR}
CACHE INTERNAL "All include dirs required for FORGE'")
ENDIF()
IF(FORGE_LIBRARY)
SET(FORGE_LIBRARIES ${FORGE_LIBRARY} ${GLFW_LIBRARY} ${GLEWmx_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
SET(FORGE_LIBRARIES ${FORGE_LIBRARY} ${GLEWmx_LIBRARY} ${OPENGL_gl_LIBRARY}
CACHE INTERNAL "All libraries required for FORGE'")
ENDIF()
# handle the QUIETLY and REQUIRED arguments and set FORGE_FOUND to TRUE if
Expand All @@ -91,12 +90,10 @@ IF(GLFW_FOUND AND GLEWmx_FOUND AND OPENGL_FOUND)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(FORGE DEFAULT_MSG FORGE_LIBRARIES FORGE_INCLUDE_DIRECTORIES)
MARK_AS_ADVANCED(FORGE_LIBRARIES FORGE_INCLUDE_DIRECTORIES)

ELSE(GLFW_FOUND AND GLEWmx_FOUND AND OPENGL_FOUND)
IF(NOT GLFW_FOUND)
MESSAGE(FATAL_ERROR "GLFW Not Found")
ELSEIF(NOT GLEWmx_FOUND)
ELSE(GLEWmx_FOUND AND OPENGL_FOUND)
IF(NOT GLEWmx_FOUND)
MESSAGE(FATAL_ERROR "GLEW-MX Not Found")
ELSEIF(NOT OPENGL_FOUND)
MESSAGE(FATAL_ERROR "OpenGL Not Found")
ENDIF()
ENDIF(GLFW_FOUND AND GLEWmx_FOUND AND OPENGL_FOUND)
ENDIF(GLEWmx_FOUND AND OPENGL_FOUND)
8 changes: 6 additions & 2 deletions CMakeModules/FindGLEWmx.cmake
Expand Up @@ -12,11 +12,15 @@
# GLEWmxd_LIBRARY
# GLEWmxs_LIBRARY

FIND_PACKAGE(GLEW)
FIND_PACKAGE(OpenGL)
FIND_PACKAGE(OpenGL REQUIRED)

OPTION(USE_GLEWmx_STATIC "Use Static GLEWmx Lib" OFF)

FIND_PATH(GLEW_INCLUDE_DIR GL/glew.h
HINTS
${GLEW_ROOT_DIR}/include
)

IF (WIN32)
FIND_LIBRARY( GLEWmxd_LIBRARY
NAMES glewmx GLEWmx glew32mx glew32mx
Expand Down
60 changes: 0 additions & 60 deletions CMakeModules/FindGLFW.cmake

This file was deleted.

2 changes: 1 addition & 1 deletion CMakeModules/Version.cmake
Expand Up @@ -3,7 +3,7 @@
#
SET(AF_VERSION_MAJOR "3")
SET(AF_VERSION_MINOR "0")
SET(AF_VERSION_PATCH "0")
SET(AF_VERSION_PATCH "1")

SET(AF_VERSION "${AF_VERSION_MAJOR}.${AF_VERSION_MINOR}.${AF_VERSION_PATCH}")
EXECUTE_PROCESS(
Expand Down
16 changes: 5 additions & 11 deletions CMakeModules/build_forge.cmake
Expand Up @@ -12,13 +12,11 @@ ELSE()
SET(byproducts BYPRODUCTS ${forge_location})
ENDIF()

INCLUDE("${CMAKE_MODULE_PATH}/FindGLEWmx.cmake")
FIND_PACKAGE(GLFW)

# FIXME Tag forge correctly during release
ExternalProject_Add(
forge-ext
GIT_REPOSITORY https://github.com/arrayfire/forge.git
GIT_TAG af3.0
GIT_TAG af3.0.1
PREFIX "${prefix}"
INSTALL_DIR "${prefix}"
UPDATE_COMMAND ""
Expand All @@ -27,15 +25,11 @@ ExternalProject_Add(
-DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}
-DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DUSE_GLEWmx_STATIC:BOOL=${USE_GLEWmx_STATIC}
-DGLEW_ROOT_DIR:STRING=${GLEW_ROOT_DIR}
-DGLFW_ROOT_DIR:STRING=${GLFW_ROOT_DIR}
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
-DBUILD_EXAMPLES:BOOL=OFF
-DUSE_GLEWmx_STATIC:BOOL=${USE_GLEWmx_STATIC}
-DGLEW_INCLUDE_DIR:PATH=${GLEW_INCLUDE_DIR}
-DGLEW_LIBRARY:FILEPATH=${GLEW_LIBRARY}
-DGLEWmxd_LIBRARY:FILEPATH=${GLEWmxd_LIBRARY}
-DGLEWmxs_LIBRARY:FILEPATH=${GLEWmxs_LIBRARY}
-DGLFW_INCLUDE_DIR:PATH=${GLFW_INCLUDE_DIR}
-DGLFW_LIBRARY:FILEPATH=${GLFW_LIBRARY}
${byproducts}
)

Expand Down
52 changes: 0 additions & 52 deletions CMakeModules/cuda_compute_capability.c

This file was deleted.

58 changes: 58 additions & 0 deletions CMakeModules/cuda_compute_capability.cpp
@@ -0,0 +1,58 @@
/*
* Copyright (C) 2011 Florian Rathgeber, florian.rathgeber@gmail.com
*
* This code is licensed under the MIT License. See the FindCUDA.cmake script
* for the text of the license.
*
* Based on code by Christopher Bruns published on Stack Overflow (CC-BY):
* http://stackoverflow.com/questions/2285185
*/

#include <stdio.h>
#include <cuda_runtime.h>
#include <iterator>
#include <set>

int main() {
int deviceCount;
int gpuDeviceCount = 0;
struct cudaDeviceProp properties;

if (cudaGetDeviceCount(&deviceCount) != cudaSuccess)
{
printf("Couldn't get device count: %s\n", cudaGetErrorString(cudaGetLastError()));
return 1;
}

std::set<int> computes;
typedef std::set<int>::iterator iter;

// machines with no GPUs can still report one emulation device
for (int device = 0; device < deviceCount; ++device) {
int major = 9999, minor = 9999;
cudaGetDeviceProperties(&properties, device);
if (properties.major != 9999) { // 9999 means emulation only
++gpuDeviceCount;
major = properties.major;
minor = properties.minor;
if ((major == 2 && minor == 1)) {
// There is no --arch compute_21 flag for nvcc, so force minor to 0
minor = 0;
}
computes.insert(10 * major + minor);
}
}
int i = 0;
for(iter it = computes.begin(); it != computes.end(); it++, i++) {
if(i > 0) {
printf(" ");
}
printf("%d", *it);
}
/* don't just return the number of gpus, because other runtime cuda
errors can also yield non-zero return values */
if (gpuDeviceCount <= 0 || computes.size() <= 0) {
return 1; // failure
}
return 0; // success
}
9 changes: 9 additions & 0 deletions CMakeModules/osx_install/InstallTool.cmake
@@ -0,0 +1,9 @@

EXECUTE_PROCESS( COMMAND otool -L ${CMAKE_CURRENT_BINARY_DIR}/package/lib/libforge.dylib
COMMAND grep glfw
COMMAND cut -d\ -f1
COMMAND xargs -Jglfwlib install_name_tool -change glfwlib /usr/local/lib/libglfw3.dylib ${CMAKE_CURRENT_BINARY_DIR}/package/lib/libforge.dylib
OUTPUT_FILE /tmp/af.out
ERROR_FILE /tmp/af.err
)

0 comments on commit 17db1c9

Please sign in to comment.