Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
cb75edd4
Commit
cb75edd4
authored
Apr 28, 2011
by
Peter Eastman
Browse files
Added pthreads library for Windows. Fixed other errors and warnings under Windows.
parent
dd352ee5
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
2291 additions
and
566 deletions
+2291
-566
CMakeLists.txt
CMakeLists.txt
+535
-522
libraries/pthreads/include/pthread.h
libraries/pthreads/include/pthread.h
+1368
-0
libraries/pthreads/include/sched.h
libraries/pthreads/include/sched.h
+178
-0
libraries/pthreads/include/semaphore.h
libraries/pthreads/include/semaphore.h
+166
-0
libraries/pthreads/lib/pthreadVC2.dll
libraries/pthreads/lib/pthreadVC2.dll
+0
-0
libraries/pthreads/lib/pthreadVC2.lib
libraries/pthreads/lib/pthreadVC2.lib
+0
-0
platforms/opencl/sharedTarget/CMakeLists.txt
platforms/opencl/sharedTarget/CMakeLists.txt
+24
-24
platforms/opencl/src/OpenCLContext.cpp
platforms/opencl/src/OpenCLContext.cpp
+2
-2
platforms/opencl/src/OpenCLIntegrationUtilities.cpp
platforms/opencl/src/OpenCLIntegrationUtilities.cpp
+1
-1
platforms/opencl/src/OpenCLKernels.cpp
platforms/opencl/src/OpenCLKernels.cpp
+9
-9
platforms/opencl/src/OpenCLNonbondedUtilities.cpp
platforms/opencl/src/OpenCLNonbondedUtilities.cpp
+1
-1
platforms/opencl/src/OpenCLParallelKernels.cpp
platforms/opencl/src/OpenCLParallelKernels.cpp
+5
-5
platforms/opencl/src/OpenCLParallelKernels.h
platforms/opencl/src/OpenCLParallelKernels.h
+1
-1
platforms/opencl/src/OpenCLSort.h
platforms/opencl/src/OpenCLSort.h
+1
-1
No files found.
CMakeLists.txt
View file @
cb75edd4
#---------------------------------------------------
#---------------------------------------------------
# OpenMM
# OpenMM
#
#
# Creates OpenMM library, base name=OpenMM.
# Creates OpenMM library, base name=OpenMM.
# Default libraries are shared & optimized. Variants
# Default libraries are shared & optimized. Variants
# are created for static (_static) and debug (_d).
# are created for static (_static) and debug (_d).
#
#
# Windows:
# Windows:
# OpenMM[_d].dll
# OpenMM[_d].dll
# OpenMM[_d].lib
# OpenMM[_d].lib
# OpenMM_static[_d].lib
# OpenMM_static[_d].lib
# Unix:
# Unix:
# libOpenMM[_d].so
# libOpenMM[_d].so
# libOpenMM_static[_d].a
# libOpenMM_static[_d].a
#----------------------------------------------------
#----------------------------------------------------
# Don't create a new project name if this is part of a mega-build from the
# Don't create a new project name if this is part of a mega-build from the
# parent directory
# parent directory
IF
(
NOT PROJECT_NAME
)
IF
(
NOT PROJECT_NAME
)
PROJECT
(
OpenMM
)
PROJECT
(
OpenMM
)
ENDIF
(
NOT PROJECT_NAME
)
ENDIF
(
NOT PROJECT_NAME
)
CMAKE_MINIMUM_REQUIRED
(
VERSION 2.8
)
CMAKE_MINIMUM_REQUIRED
(
VERSION 2.8
)
#SET(CMAKE_VERBOSE_MAKEFILE 1)
#SET(CMAKE_VERBOSE_MAKEFILE 1)
# CMake 2.4 on dart server only needs to know about Dart
# CMake 2.4 on dart server only needs to know about Dart
INCLUDE
(
Dart
)
INCLUDE
(
Dart
)
MARK_AS_ADVANCED
(
DART_ROOT
)
MARK_AS_ADVANCED
(
DART_ROOT
)
# Avoid dart server problem with cmake 2.4 --cmb
# Avoid dart server problem with cmake 2.4 --cmb
set
(
cmv
"
${
CMAKE_MAJOR_VERSION
}
.
${
CMAKE_MINOR_VERSION
}
"
)
set
(
cmv
"
${
CMAKE_MAJOR_VERSION
}
.
${
CMAKE_MINOR_VERSION
}
"
)
IF
(
NOT cmv EQUAL
"2.4"
)
# This whole file...
IF
(
NOT cmv EQUAL
"2.4"
)
# This whole file...
# We have custom cmake modules for FindOpenMM and running python tests
# We have custom cmake modules for FindOpenMM and running python tests
SET
(
CMAKE_MODULE_PATH
${
CMAKE_MODULE_PATH
}
"
${
CMAKE_SOURCE_DIR
}
/cmake_modules"
)
SET
(
CMAKE_MODULE_PATH
${
CMAKE_MODULE_PATH
}
"
${
CMAKE_SOURCE_DIR
}
/cmake_modules"
)
# Older cmake versions do not have cmake_policy command
# Older cmake versions do not have cmake_policy command
# Cmake 2.4.5, the default cmake on red hat linux, has the
# Cmake 2.4.5, the default cmake on red hat linux, has the
# cmake_policy command, but it does not work
# cmake_policy command, but it does not work
# "if(POLICY ..." does not work with cmake 2.4.[56] on red hat
# "if(POLICY ..." does not work with cmake 2.4.[56] on red hat
# (cmake 2.4.7 is OK)
# (cmake 2.4.7 is OK)
if
(
COMMAND cmake_policy
)
if
(
COMMAND cmake_policy
)
if
(
CMAKE_MAJOR_VERSION GREATER 2 OR CMAKE_MINOR_VERSION GREATER 5
)
if
(
CMAKE_MAJOR_VERSION GREATER 2 OR CMAKE_MINOR_VERSION GREATER 5
)
cmake_policy
(
SET CMP0003 NEW
)
cmake_policy
(
SET CMP0003 NEW
)
cmake_policy
(
SET CMP0005 NEW
)
cmake_policy
(
SET CMP0005 NEW
)
endif
(
CMAKE_MAJOR_VERSION GREATER 2 OR CMAKE_MINOR_VERSION GREATER 5
)
endif
(
CMAKE_MAJOR_VERSION GREATER 2 OR CMAKE_MINOR_VERSION GREATER 5
)
if
(
CMAKE_MAJOR_VERSION GREATER 2 OR CMAKE_MINOR_VERSION GREATER 6 OR CMAKE_PATCH_VERSION GREATER 2
)
if
(
CMAKE_MAJOR_VERSION GREATER 2 OR CMAKE_MINOR_VERSION GREATER 6 OR CMAKE_PATCH_VERSION GREATER 2
)
cmake_policy
(
SET CMP0011 NEW
)
cmake_policy
(
SET CMP0011 NEW
)
endif
(
CMAKE_MAJOR_VERSION GREATER 2 OR CMAKE_MINOR_VERSION GREATER 6 OR CMAKE_PATCH_VERSION GREATER 2
)
endif
(
CMAKE_MAJOR_VERSION GREATER 2 OR CMAKE_MINOR_VERSION GREATER 6 OR CMAKE_PATCH_VERSION GREATER 2
)
endif
(
COMMAND cmake_policy
)
endif
(
COMMAND cmake_policy
)
# Where to install
# Where to install
IF
(
${
CMAKE_C_COMPILER
}
MATCHES
"gcc"
)
IF
(
${
CMAKE_C_COMPILER
}
MATCHES
"gcc"
)
IF
(
NOT OPENMM_INSTALL_PREFIX
)
IF
(
NOT OPENMM_INSTALL_PREFIX
)
SET
(
OPENMM_INSTALL_PREFIX
"/usr/local/openmm"
CACHE PATH
"Where to install OpenMM"
)
SET
(
OPENMM_INSTALL_PREFIX
"/usr/local/openmm"
CACHE PATH
"Where to install OpenMM"
)
ENDIF
(
NOT OPENMM_INSTALL_PREFIX
)
ENDIF
(
NOT OPENMM_INSTALL_PREFIX
)
ELSE
(
${
CMAKE_C_COMPILER
}
MATCHES
"gcc"
)
ELSE
(
${
CMAKE_C_COMPILER
}
MATCHES
"gcc"
)
IF
(
NOT OPENMM_INSTALL_PREFIX
)
IF
(
NOT OPENMM_INSTALL_PREFIX
)
SET
(
OPENMM_INSTALL_PREFIX
"$ENV{ProgramFiles}/OpenMM"
CACHE PATH
"Where to install OpenMM"
)
SET
(
OPENMM_INSTALL_PREFIX
"$ENV{ProgramFiles}/OpenMM"
CACHE PATH
"Where to install OpenMM"
)
ENDIF
(
NOT OPENMM_INSTALL_PREFIX
)
ENDIF
(
NOT OPENMM_INSTALL_PREFIX
)
ENDIF
(
${
CMAKE_C_COMPILER
}
MATCHES
"gcc"
)
ENDIF
(
${
CMAKE_C_COMPILER
}
MATCHES
"gcc"
)
MARK_AS_ADVANCED
(
OPENMM_INSTALL_PREFIX
)
MARK_AS_ADVANCED
(
OPENMM_INSTALL_PREFIX
)
# It seems that on linux and mac, everything is trying to be installed in /usr/local/openmm
# It seems that on linux and mac, everything is trying to be installed in /usr/local/openmm
# But if every install target is prefixed with /openmm/, on Windows the install files
# But if every install target is prefixed with /openmm/, on Windows the install files
# end up in C:/Program Files/OpenMM/openmm/ which is ugly.
# end up in C:/Program Files/OpenMM/openmm/ which is ugly.
# Better to set CMAKE_INSTALL_PREFIX to /usr/local/openmm and leave /openmm/ off the
# Better to set CMAKE_INSTALL_PREFIX to /usr/local/openmm and leave /openmm/ off the
# install target names. Plus, the user now has the opportunity to install into /usr/local/
# install target names. Plus, the user now has the opportunity to install into /usr/local/
# if she so chooses. --cmb
# if she so chooses. --cmb
IF
(
${
CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT
}
)
IF
(
${
CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT
}
)
SET
(
CMAKE_INSTALL_PREFIX
${
OPENMM_INSTALL_PREFIX
}
CACHE PATH
"Where to install OpenMM"
FORCE
)
SET
(
CMAKE_INSTALL_PREFIX
${
OPENMM_INSTALL_PREFIX
}
CACHE PATH
"Where to install OpenMM"
FORCE
)
ENDIF
(
${
CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT
}
)
ENDIF
(
${
CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT
}
)
# The source is organized into subdirectories, but we handle them all from
# The source is organized into subdirectories, but we handle them all from
# this CMakeLists file rather than letting CMake visit them as SUBDIRS.
# this CMakeLists file rather than letting CMake visit them as SUBDIRS.
SET
(
OPENMM_SOURCE_SUBDIRS . openmmapi olla libraries/jama libraries/quern libraries/lepton libraries/sfmt libraries/lbfgs platforms/reference libraries/validate
)
SET
(
OPENMM_SOURCE_SUBDIRS . openmmapi olla libraries/jama libraries/quern libraries/lepton libraries/sfmt libraries/lbfgs platforms/reference libraries/validate
)
IF
(
WIN32
)
# The build system will set ARCH64 for 64 bit builds, which require
SET
(
OPENMM_SOURCE_SUBDIRS
${
OPENMM_SOURCE_SUBDIRS
}
libraries/pthreads
)
# use of the lib64/ library directories rather than lib/.
ADD_CUSTOM_TARGET
(
PthreadsLibraries ALL
)
#SET( ARCH64 OFF CACHE BOOL "ON for 64bit builds, OFF for 32bit builds")
FILE
(
GLOB PTHREADS_LIBRARIES libraries/pthreads/lib/*
)
#MARK_AS_ADVANCED( ARCH64 )
FOREACH
(
lib
${
PTHREADS_LIBRARIES
}
)
#IF (ARCH64)
ADD_CUSTOM_COMMAND
(
TARGET PthreadsLibraries COMMAND
${
CMAKE_COMMAND
}
ARGS -E copy
${
lib
}
"
${
CMAKE_CURRENT_BINARY_DIR
}
/
${
CMAKE_CFG_INTDIR
}
"
)
# SET(LIB64 64)
INSTALL
(
FILES
${
lib
}
DESTINATION
"lib/"
)
#ELSE (ARCH64)
ENDFOREACH
(
lib
)
# SET(LIB64) # nothing
LINK_DIRECTORIES
(
"
${
CMAKE_CURRENT_BINARY_DIR
}
/
${
CMAKE_CFG_INTDIR
}
"
)
#ENDIF (ARCH64)
SET
(
PTHREADS_LIB pthreadVC2
)
ELSE
(
WIN32
)
IF
(
CMAKE_SIZEOF_VOID_P EQUAL 8
)
SET
(
PTHREADS_LIB pthread
)
SET
(
LIB64 64
)
ENDIF
(
WIN32
)
ELSE
(
CMAKE_SIZEOF_VOID_P EQUAL 8
)
SET
(
LIB64
)
# The build system will set ARCH64 for 64 bit builds, which require
ENDIF
(
CMAKE_SIZEOF_VOID_P EQUAL 8
)
# use of the lib64/ library directories rather than lib/.
#SET( ARCH64 OFF CACHE BOOL "ON for 64bit builds, OFF for 32bit builds")
# Build universal binaries compatible with OS X 10.5
#MARK_AS_ADVANCED( ARCH64 )
IF
(
APPLE AND NOT CMAKE_OSX_DEPLOYMENT_TARGET
)
#IF (ARCH64)
SET
(
CMAKE_OSX_ARCHITECTURES
"i386;x86_64"
CACHE STRING
"The processor architectures to build for"
FORCE
)
# SET(LIB64 64)
SET
(
CMAKE_OSX_DEPLOYMENT_TARGET
"10.5"
CACHE STRING
"The minimum version of OS X to support"
FORCE
)
#ELSE (ARCH64)
SET
(
CMAKE_OSX_SYSROOT
"/Developer/SDKs/MacOSX10.5.sdk"
CACHE STRING
"The SDK to build against"
FORCE
)
# SET(LIB64) # nothing
ENDIF
(
APPLE AND NOT CMAKE_OSX_DEPLOYMENT_TARGET
)
#ENDIF (ARCH64)
IF
(
UNIX AND NOT CMAKE_BUILD_TYPE
)
IF
(
CMAKE_SIZEOF_VOID_P EQUAL 8
)
SET
(
CMAKE_BUILD_TYPE Release CACHE STRING
"Debug or Release build"
FORCE
)
SET
(
LIB64 64
)
ENDIF
(
UNIX AND NOT CMAKE_BUILD_TYPE
)
ELSE
(
CMAKE_SIZEOF_VOID_P EQUAL 8
)
SET
(
LIB64
)
IF
(
NOT CMAKE_CXX_FLAGS_DEBUG
)
ENDIF
(
CMAKE_SIZEOF_VOID_P EQUAL 8
)
SET
(
CMAKE_CXX_FLAGS_DEBUG
"-g"
CACHE STRING
"To use when CMAKE_BUILD_TYPE=Debug"
FORCE
)
ENDIF
(
NOT CMAKE_CXX_FLAGS_DEBUG
)
# Build universal binaries compatible with OS X 10.5
IF
(
APPLE AND NOT CMAKE_OSX_DEPLOYMENT_TARGET
)
IF
(
NOT CMAKE_CXX_FLAGS_RELEASE
)
SET
(
CMAKE_OSX_ARCHITECTURES
"i386;x86_64"
CACHE STRING
"The processor architectures to build for"
FORCE
)
SET
(
CMAKE_CXX_FLAGS_RELEASE
"-O3 -DNDEBUG"
CACHE STRING
SET
(
CMAKE_OSX_DEPLOYMENT_TARGET
"10.5"
CACHE STRING
"The minimum version of OS X to support"
FORCE
)
"To use when CMAKE_BUILD_TYPE=Release"
FORCE
)
SET
(
CMAKE_OSX_SYSROOT
"/Developer/SDKs/MacOSX10.5.sdk"
CACHE STRING
"The SDK to build against"
FORCE
)
ENDIF
(
NOT CMAKE_CXX_FLAGS_RELEASE
)
ENDIF
(
APPLE AND NOT CMAKE_OSX_DEPLOYMENT_TARGET
)
IF
(
UNIX AND NOT CMAKE_BUILD_TYPE
)
SET
(
CMAKE_BUILD_TYPE Release CACHE STRING
"Debug or Release build"
FORCE
)
# Collect up information about the version of the OpenMM library we're building
ENDIF
(
UNIX AND NOT CMAKE_BUILD_TYPE
)
# and make it available to the code so it can be built into the binaries.
IF
(
NOT CMAKE_CXX_FLAGS_DEBUG
)
SET
(
OPENMM_LIBRARY_NAME OpenMM
)
SET
(
CMAKE_CXX_FLAGS_DEBUG
"-g"
CACHE STRING
"To use when CMAKE_BUILD_TYPE=Debug"
FORCE
)
SET
(
OPENMM_MAJOR_VERSION 1
)
ENDIF
(
NOT CMAKE_CXX_FLAGS_DEBUG
)
SET
(
OPENMM_MINOR_VERSION 0
)
SET
(
OPENMM_BUILD_VERSION 0
)
IF
(
NOT CMAKE_CXX_FLAGS_RELEASE
)
SET
(
CMAKE_CXX_FLAGS_RELEASE
"-O3 -DNDEBUG"
CACHE STRING
SET
(
OPENMM_COPYRIGHT_YEARS
"2008"
)
"To use when CMAKE_BUILD_TYPE=Release"
FORCE
)
ENDIF
(
NOT CMAKE_CXX_FLAGS_RELEASE
)
# underbar separated list of dotted authors, no spaces or commas
SET
(
OPENMM_AUTHORS
"Peter.Eastman"
)
# Get the subversion revision number if we can
# Collect up information about the version of the OpenMM library we're building
# It's possible that WIN32 installs use svnversion through cygwin
# and make it available to the code so it can be built into the binaries.
# so we'll try for both svnversion.exe and svnversion. Note that
# this will result in warnings if all you have is Tortoise without
SET
(
OPENMM_LIBRARY_NAME OpenMM
)
# Cygwin, and your "about" string will say "unknown" rather than
SET
(
OPENMM_MAJOR_VERSION 1
)
# providing the SVN version of the source.
SET
(
OPENMM_MINOR_VERSION 0
)
SET
(
OPENMM_BUILD_VERSION 0
)
FIND_PROGRAM
(
SVNVERSION_PROGRAM svnversion
PATHS
"C:/cygwin/bin"
SET
(
OPENMM_COPYRIGHT_YEARS
"2008"
)
)
IF
(
SVNVERSION_PROGRAM
)
# underbar separated list of dotted authors, no spaces or commas
EXEC_PROGRAM
(
${
SVNVERSION_PROGRAM
}
SET
(
OPENMM_AUTHORS
"Peter.Eastman"
)
ARGS \"
${
CMAKE_CURRENT_SOURCE_DIR
}
\"
OUTPUT_VARIABLE OPENMM_SVN_REVISION
)
# Get the subversion revision number if we can
ELSE
(
SVNVERSION_PROGRAM
)
# It's possible that WIN32 installs use svnversion through cygwin
MESSAGE
(
STATUS
# so we'll try for both svnversion.exe and svnversion. Note that
"Could not find 'svnversion' executable; 'about' will be wrong. (Cygwin provides one on Windows.)"
# this will result in warnings if all you have is Tortoise without
)
# Cygwin, and your "about" string will say "unknown" rather than
SET
(
OPENMM_SVN_REVISION unknown
)
# providing the SVN version of the source.
ENDIF
(
SVNVERSION_PROGRAM
)
FIND_PROGRAM
(
SVNVERSION_PROGRAM svnversion
# Remove colon from build version, for easier placement in directory names
PATHS
"C:/cygwin/bin"
STRING
(
REPLACE
":"
"_"
OPENMM_SVN_REVISION
${
OPENMM_SVN_REVISION
}
)
)
SET
(
OPENMM_SVN_REVISION
"
${
OPENMM_SVN_REVISION
}
"
CACHE STRING
"subversion repository revision of OpenMM"
FORCE
)
IF
(
SVNVERSION_PROGRAM
)
EXEC_PROGRAM
(
${
SVNVERSION_PROGRAM
}
ADD_DEFINITIONS
(
-DOPENMM_LIBRARY_NAME=
${
OPENMM_LIBRARY_NAME
}
ARGS \"
${
CMAKE_CURRENT_SOURCE_DIR
}
\"
-DOPENMM_MAJOR_VERSION=
${
OPENMM_MAJOR_VERSION
}
OUTPUT_VARIABLE OPENMM_SVN_REVISION
)
-DOPENMM_MINOR_VERSION=
${
OPENMM_MINOR_VERSION
}
ELSE
(
SVNVERSION_PROGRAM
)
-DOPENMM_BUILD_VERSION=
${
OPENMM_BUILD_VERSION
}
)
MESSAGE
(
STATUS
"Could not find 'svnversion' executable; 'about' will be wrong. (Cygwin provides one on Windows.)"
# CMake quotes automatically when building Visual Studio projects but we need
)
# to add them ourselves for Linux or Cygwin. Two cases to avoid duplicate quotes
SET
(
OPENMM_SVN_REVISION unknown
)
# in Visual Studio which end up in the binary.
ENDIF
(
SVNVERSION_PROGRAM
)
IF
(
${
CMAKE_GENERATOR
}
MATCHES
"Visual Studio"
)
# Remove colon from build version, for easier placement in directory names
SET
(
NEED_QUOTES FALSE
)
STRING
(
REPLACE
":"
"_"
OPENMM_SVN_REVISION
${
OPENMM_SVN_REVISION
}
)
ELSE
(
${
CMAKE_GENERATOR
}
MATCHES
"Visual Studio"
)
SET
(
OPENMM_SVN_REVISION
"
${
OPENMM_SVN_REVISION
}
"
CACHE STRING
"subversion repository revision of OpenMM"
FORCE
)
SET
(
NEED_QUOTES TRUE
)
ENDIF
(
${
CMAKE_GENERATOR
}
MATCHES
"Visual Studio"
)
ADD_DEFINITIONS
(
-DOPENMM_LIBRARY_NAME=
${
OPENMM_LIBRARY_NAME
}
-DOPENMM_MAJOR_VERSION=
${
OPENMM_MAJOR_VERSION
}
##TODO: doesn't work without quotes in nightly build
-DOPENMM_MINOR_VERSION=
${
OPENMM_MINOR_VERSION
}
SET
(
NEED_QUOTES TRUE
)
-DOPENMM_BUILD_VERSION=
${
OPENMM_BUILD_VERSION
}
)
IF
(
NEED_QUOTES
)
# CMake quotes automatically when building Visual Studio projects but we need
ADD_DEFINITIONS
(
-DOPENMM_SVN_REVISION=
"
${
OPENMM_SVN_REVISION
}
"
# to add them ourselves for Linux or Cygwin. Two cases to avoid duplicate quotes
-DOPENMM_COPYRIGHT_YEARS=
"
${
OPENMM_COPYRIGHT_YEARS
}
"
# in Visual Studio which end up in the binary.
-DOPENMM_AUTHORS=
"
${
OPENMM_AUTHORS
}
"
)
ELSE
(
NEED_QUOTES
)
IF
(
${
CMAKE_GENERATOR
}
MATCHES
"Visual Studio"
)
ADD_DEFINITIONS
(
-DOPENMM_SVN_REVISION=
${
OPENMM_SVN_REVISION
}
SET
(
NEED_QUOTES FALSE
)
-DOPENMM_COPYRIGHT_YEARS=
${
OPENMM_COPYRIGHT_YEARS
}
ELSE
(
${
CMAKE_GENERATOR
}
MATCHES
"Visual Studio"
)
-DOPENMM_AUTHORS=
${
OPENMM_AUTHORS
}
)
SET
(
NEED_QUOTES TRUE
)
ENDIF
(
NEED_QUOTES
)
ENDIF
(
${
CMAKE_GENERATOR
}
MATCHES
"Visual Studio"
)
# -DOPENMM_TYPE has to be defined in the target subdirectories.
##TODO: doesn't work without quotes in nightly build
# -Dsimbody_EXPORTS defined automatically when Windows DLL build is being done.
SET
(
NEED_QUOTES TRUE
)
# Report the version number to the CMake UI
IF
(
NEED_QUOTES
)
SET
(
OPENMM_VERSION
ADD_DEFINITIONS
(
-DOPENMM_SVN_REVISION=
"
${
OPENMM_SVN_REVISION
}
"
"
${
OPENMM_MAJOR_VERSION
}
.
${
OPENMM_MINOR_VERSION
}
.
${
OPENMM_BUILD_VERSION
}
"
-DOPENMM_COPYRIGHT_YEARS=
"
${
OPENMM_COPYRIGHT_YEARS
}
"
CACHE STRING
"This is the version of OpenMM which will be built."
FORCE
)
-DOPENMM_AUTHORS=
"
${
OPENMM_AUTHORS
}
"
)
# We don't actually use this version for anything yet
ELSE
(
NEED_QUOTES
)
MARK_AS_ADVANCED
(
OPENMM_VERSION
)
ADD_DEFINITIONS
(
-DOPENMM_SVN_REVISION=
${
OPENMM_SVN_REVISION
}
-DOPENMM_COPYRIGHT_YEARS=
${
OPENMM_COPYRIGHT_YEARS
}
SET
(
SHARED_TARGET
${
OPENMM_LIBRARY_NAME
}
)
-DOPENMM_AUTHORS=
${
OPENMM_AUTHORS
}
)
SET
(
STATIC_TARGET
${
OPENMM_LIBRARY_NAME
}
_static
)
ENDIF
(
NEED_QUOTES
)
# -DOPENMM_TYPE has to be defined in the target subdirectories.
## If no one says otherwise, change the executable path to drop into the same binary
# -Dsimbody_EXPORTS defined automatically when Windows DLL build is being done.
## location as the DLLs so that the test cases will use the just-build DLLs.
IF
(
NOT EXECUTABLE_OUTPUT_PATH
)
# Report the version number to the CMake UI
SET
(
EXECUTABLE_OUTPUT_PATH
${
PROJECT_BINARY_DIR
}
SET
(
OPENMM_VERSION
CACHE INTERNAL
"Single output directory for building all executables."
)
"
${
OPENMM_MAJOR_VERSION
}
.
${
OPENMM_MINOR_VERSION
}
.
${
OPENMM_BUILD_VERSION
}
"
ENDIF
(
NOT EXECUTABLE_OUTPUT_PATH
)
CACHE STRING
"This is the version of OpenMM which will be built."
FORCE
)
IF
(
NOT LIBRARY_OUTPUT_PATH
)
# We don't actually use this version for anything yet
SET
(
LIBRARY_OUTPUT_PATH
${
PROJECT_BINARY_DIR
}
MARK_AS_ADVANCED
(
OPENMM_VERSION
)
CACHE INTERNAL
"Single output directory for building all libraries."
)
ENDIF
(
NOT LIBRARY_OUTPUT_PATH
)
SET
(
SHARED_TARGET
${
OPENMM_LIBRARY_NAME
}
)
SET
(
${
PROJECT_NAME
}
_EXECUTABLE_DIR
${
EXECUTABLE_OUTPUT_PATH
}
/
${
CMAKE_CFG_INTDIR
}
)
SET
(
STATIC_TARGET
${
OPENMM_LIBRARY_NAME
}
_static
)
SET
(
${
PROJECT_NAME
}
_LIBRARY_DIR
${
LIBRARY_OUTPUT_PATH
}
/
${
CMAKE_CFG_INTDIR
}
)
# Ensure that debug libraries have "_d" appended to their names.
## If no one says otherwise, change the executable path to drop into the same binary
# CMake gets this right on Windows automatically with this definition.
## location as the DLLs so that the test cases will use the just-build DLLs.
IF
(
${
CMAKE_GENERATOR
}
MATCHES
"Visual Studio"
)
IF
(
NOT EXECUTABLE_OUTPUT_PATH
)
SET
(
CMAKE_DEBUG_POSTFIX
"_d"
CACHE INTERNAL
""
FORCE
)
SET
(
EXECUTABLE_OUTPUT_PATH
${
PROJECT_BINARY_DIR
}
ENDIF
(
${
CMAKE_GENERATOR
}
MATCHES
"Visual Studio"
)
CACHE INTERNAL
"Single output directory for building all executables."
)
ENDIF
(
NOT EXECUTABLE_OUTPUT_PATH
)
# But on Unix or Cygwin we have to add the suffix manually
IF
(
NOT LIBRARY_OUTPUT_PATH
)
IF
(
UNIX AND CMAKE_BUILD_TYPE MATCHES Debug
)
SET
(
LIBRARY_OUTPUT_PATH
${
PROJECT_BINARY_DIR
}
SET
(
SHARED_TARGET
${
SHARED_TARGET
}
_d
)
CACHE INTERNAL
"Single output directory for building all libraries."
)
SET
(
STATIC_TARGET
${
STATIC_TARGET
}
_d
)
ENDIF
(
NOT LIBRARY_OUTPUT_PATH
)
ENDIF
(
UNIX AND CMAKE_BUILD_TYPE MATCHES Debug
)
SET
(
${
PROJECT_NAME
}
_EXECUTABLE_DIR
${
EXECUTABLE_OUTPUT_PATH
}
/
${
CMAKE_CFG_INTDIR
}
)
SET
(
${
PROJECT_NAME
}
_LIBRARY_DIR
${
LIBRARY_OUTPUT_PATH
}
/
${
CMAKE_CFG_INTDIR
}
)
# used by plugin
SET
(
OPENMM_DIR
${
CMAKE_CURRENT_SOURCE_DIR
}
)
# Ensure that debug libraries have "_d" appended to their names.
# CMake gets this right on Windows automatically with this definition.
# These are all the places to search for header files which are
IF
(
${
CMAKE_GENERATOR
}
MATCHES
"Visual Studio"
)
# to be part of the API.
SET
(
CMAKE_DEBUG_POSTFIX
"_d"
CACHE INTERNAL
""
FORCE
)
SET
(
API_INCLUDE_DIRS
)
# start empty
ENDIF
(
${
CMAKE_GENERATOR
}
MATCHES
"Visual Studio"
)
FOREACH
(
subdir
${
OPENMM_SOURCE_SUBDIRS
}
)
# append
# But on Unix or Cygwin we have to add the suffix manually
SET
(
API_INCLUDE_DIRS
${
API_INCLUDE_DIRS
}
IF
(
UNIX AND CMAKE_BUILD_TYPE MATCHES Debug
)
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
subdir
}
/include
SET
(
SHARED_TARGET
${
SHARED_TARGET
}
_d
)
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
subdir
}
/include/openmm
SET
(
STATIC_TARGET
${
STATIC_TARGET
}
_d
)
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
subdir
}
/include/openmm/internal
)
ENDIF
(
UNIX AND CMAKE_BUILD_TYPE MATCHES Debug
)
ENDFOREACH
(
subdir
)
# used by plugin
# We'll need both *relative* path names, starting with their API_INCLUDE_DIRS,
SET
(
OPENMM_DIR
${
CMAKE_CURRENT_SOURCE_DIR
}
)
# and absolute pathnames.
SET
(
API_REL_INCLUDE_FILES
)
# start these out empty
# These are all the places to search for header files which are
SET
(
API_ABS_INCLUDE_FILES
)
# to be part of the API.
SET
(
API_INCLUDE_DIRS
)
# start empty
FOREACH
(
dir
${
API_INCLUDE_DIRS
}
)
FOREACH
(
subdir
${
OPENMM_SOURCE_SUBDIRS
}
)
FILE
(
GLOB fullpaths
${
dir
}
/*.h
)
# returns full pathnames
# append
SET
(
API_ABS_INCLUDE_FILES
${
API_ABS_INCLUDE_FILES
}
${
fullpaths
}
)
SET
(
API_INCLUDE_DIRS
${
API_INCLUDE_DIRS
}
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
subdir
}
/include
FOREACH
(
pathname
${
fullpaths
}
)
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
subdir
}
/include/openmm
GET_FILENAME_COMPONENT
(
filename
${
pathname
}
NAME
)
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
subdir
}
/include/openmm/internal
)
SET
(
API_REL_INCLUDE_FILES
${
API_REL_INCLUDE_FILES
}
${
dir
}
/
${
filename
}
)
ENDFOREACH
(
subdir
)
ENDFOREACH
(
pathname
)
ENDFOREACH
(
dir
)
# We'll need both *relative* path names, starting with their API_INCLUDE_DIRS,
# and absolute pathnames.
# collect up source files
SET
(
API_REL_INCLUDE_FILES
)
# start these out empty
SET
(
SOURCE_FILES
)
# empty
SET
(
API_ABS_INCLUDE_FILES
)
SET
(
SOURCE_INCLUDE_FILES
)
FOREACH
(
dir
${
API_INCLUDE_DIRS
}
)
FOREACH
(
subdir
${
OPENMM_SOURCE_SUBDIRS
}
)
FILE
(
GLOB fullpaths
${
dir
}
/*.h
)
# returns full pathnames
FILE
(
GLOB src_files
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
subdir
}
/src/*.cpp
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
subdir
}
/src/*/*.cpp
)
SET
(
API_ABS_INCLUDE_FILES
${
API_ABS_INCLUDE_FILES
}
${
fullpaths
}
)
FILE
(
GLOB incl_files
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
subdir
}
/src/*.h
)
SET
(
SOURCE_FILES
${
SOURCE_FILES
}
${
src_files
}
)
#append
FOREACH
(
pathname
${
fullpaths
}
)
SET
(
SOURCE_INCLUDE_FILES
${
SOURCE_INCLUDE_FILES
}
${
incl_files
}
)
GET_FILENAME_COMPONENT
(
filename
${
pathname
}
NAME
)
SET
(
API_REL_INCLUDE_FILES
${
API_REL_INCLUDE_FILES
}
${
dir
}
/
${
filename
}
)
## Make sure we find these locally before looking in OpenMM/include if
ENDFOREACH
(
pathname
)
## OpenMM was previously installed there.
ENDFOREACH
(
dir
)
INCLUDE_DIRECTORIES
(
BEFORE
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
subdir
}
/include
)
ENDFOREACH
(
subdir
)
# collect up source files
SET
(
SOURCE_FILES
)
# empty
# If API wrappers are being generated, and add them to the build.
SET
(
SOURCE_INCLUDE_FILES
)
# Java and gccxml are required for API wrappers
FIND_PACKAGE
(
Java
)
FOREACH
(
subdir
${
OPENMM_SOURCE_SUBDIRS
}
)
MARK_AS_ADVANCED
(
CLEAR JAVA_RUNTIME
)
FILE
(
GLOB src_files
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
subdir
}
/src/*.cpp
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
subdir
}
/src/*/*.cpp
)
# One particular location to try first for nightly builds
FILE
(
GLOB incl_files
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
subdir
}
/src/*.h
)
FIND_PROGRAM
(
GCCXML_PATH gccxml PATH
SET
(
SOURCE_FILES
${
SOURCE_FILES
}
${
src_files
}
)
#append
"C:/Program Files/gccxml_sherm/bin"
)
SET
(
SOURCE_INCLUDE_FILES
${
SOURCE_INCLUDE_FILES
}
${
incl_files
}
)
# In case first attempt fails
FIND_PROGRAM
(
GCCXML_PATH gccxml PATH
## Make sure we find these locally before looking in OpenMM/include if
/usr/local/bin
## OpenMM was previously installed there.
"C:/Program Files/gccxml 0.9/bin"
INCLUDE_DIRECTORIES
(
BEFORE
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
subdir
}
/include
)
)
ENDFOREACH
(
subdir
)
IF
(
GCCXML_PATH AND JAVA_RUNTIME AND NOT cmv EQUAL
"2.4"
)
SET
(
OPENMM_BUILD_C_AND_FORTRAN_WRAPPERS ON CACHE BOOL
"Build wrappers for C and Fortran"
)
# If API wrappers are being generated, and add them to the build.
ELSE
(
GCCXML_PATH AND JAVA_RUNTIME AND NOT cmv EQUAL
"2.4"
)
# Java and gccxml are required for API wrappers
SET
(
OPENMM_BUILD_C_AND_FORTRAN_WRAPPERS OFF CACHE BOOL
"Build wrappers for C and Fortran"
)
FIND_PACKAGE
(
Java
)
ENDIF
(
GCCXML_PATH AND JAVA_RUNTIME AND NOT cmv EQUAL
"2.4"
)
MARK_AS_ADVANCED
(
CLEAR JAVA_RUNTIME
)
IF
(
OPENMM_BUILD_C_AND_FORTRAN_WRAPPERS
)
# One particular location to try first for nightly builds
ADD_SUBDIRECTORY
(
wrappers
)
FIND_PROGRAM
(
GCCXML_PATH gccxml PATH
SET
(
SOURCE_FILES
${
SOURCE_FILES
}
wrappers/OpenMMCWrapper.cpp wrappers/OpenMMFortranWrapper.cpp
)
"C:/Program Files/gccxml_sherm/bin"
)
SET_SOURCE_FILES_PROPERTIES
(
wrappers/OpenMMCWrapper.cpp wrappers/OpenMMFortranWrapper.cpp PROPERTIES GENERATED TRUE
)
# In case first attempt fails
ENDIF
(
OPENMM_BUILD_C_AND_FORTRAN_WRAPPERS
)
FIND_PROGRAM
(
GCCXML_PATH gccxml PATH
/usr/local/bin
INCLUDE_DIRECTORIES
(
BEFORE
${
CMAKE_CURRENT_SOURCE_DIR
}
/src
)
"C:/Program Files/gccxml 0.9/bin"
)
ADD_LIBRARY
(
${
SHARED_TARGET
}
SHARED
${
SOURCE_FILES
}
${
SOURCE_INCLUDE_FILES
}
${
API_ABS_INCLUDE_FILES
}
)
IF
(
GCCXML_PATH AND JAVA_RUNTIME AND NOT cmv EQUAL
"2.4"
)
SET_TARGET_PROPERTIES
(
${
SHARED_TARGET
}
PROPERTIES COMPILE_FLAGS
"-DOPENMM_BUILDING_SHARED_LIBRARY -DLEPTON_BUILDING_SHARED_LIBRARY -DOPENMM_VALIDATE_BUILDING_SHARED_LIBRARY"
)
SET
(
OPENMM_BUILD_C_AND_FORTRAN_WRAPPERS ON CACHE BOOL
"Build wrappers for C and Fortran"
)
ELSE
(
GCCXML_PATH AND JAVA_RUNTIME AND NOT cmv EQUAL
"2.4"
)
SET
(
OPENMM_BUILD_STATIC_LIB OFF CACHE BOOL
"Whether to build static OpenMM libraries"
)
SET
(
OPENMM_BUILD_C_AND_FORTRAN_WRAPPERS OFF CACHE BOOL
"Build wrappers for C and Fortran"
)
IF
(
OPENMM_BUILD_STATIC_LIB
)
ENDIF
(
GCCXML_PATH AND JAVA_RUNTIME AND NOT cmv EQUAL
"2.4"
)
ADD_LIBRARY
(
${
STATIC_TARGET
}
STATIC
${
SOURCE_FILES
}
${
SOURCE_INCLUDE_FILES
}
${
API_ABS_INCLUDE_FILES
}
)
IF
(
OPENMM_BUILD_C_AND_FORTRAN_WRAPPERS
)
SET_TARGET_PROPERTIES
(
${
STATIC_TARGET
}
PROPERTIES COMPILE_FLAGS
"-DOPENMM_USE_STATIC_LIBRARIES -DOPENMM_BUILDING_STATIC_LIBRARY -DLEPTON_USE_STATIC_LIBRARIES -DLEPTON_BUILDING_STATIC_LIBRARY -DOPENMMM_VALIDATE_BUILDING_STATIC_LIBRARY -DOPENMM_VALIDATE_BUILDING_STATIC_LIBRARY"
)
ADD_SUBDIRECTORY
(
wrappers
)
ENDIF
(
OPENMM_BUILD_STATIC_LIB
)
SET
(
SOURCE_FILES
${
SOURCE_FILES
}
wrappers/OpenMMCWrapper.cpp wrappers/OpenMMFortranWrapper.cpp
)
SET_SOURCE_FILES_PROPERTIES
(
wrappers/OpenMMCWrapper.cpp wrappers/OpenMMFortranWrapper.cpp PROPERTIES GENERATED TRUE
)
IF
(
OPENMM_BUILD_C_AND_FORTRAN_WRAPPERS
)
ENDIF
(
OPENMM_BUILD_C_AND_FORTRAN_WRAPPERS
)
ADD_DEPENDENCIES
(
${
SHARED_TARGET
}
ApiWrappers
)
IF
(
OPENMM_BUILD_STATIC_LIB
)
INCLUDE_DIRECTORIES
(
BEFORE
${
CMAKE_CURRENT_SOURCE_DIR
}
/src
)
ADD_DEPENDENCIES
(
${
STATIC_TARGET
}
ApiWrappers
)
ENDIF
(
OPENMM_BUILD_STATIC_LIB
)
ADD_LIBRARY
(
${
SHARED_TARGET
}
SHARED
${
SOURCE_FILES
}
${
SOURCE_INCLUDE_FILES
}
${
API_ABS_INCLUDE_FILES
}
)
ENDIF
(
OPENMM_BUILD_C_AND_FORTRAN_WRAPPERS
)
SET_TARGET_PROPERTIES
(
${
SHARED_TARGET
}
PROPERTIES COMPILE_FLAGS
"-DOPENMM_BUILDING_SHARED_LIBRARY -DLEPTON_BUILDING_SHARED_LIBRARY -DOPENMM_VALIDATE_BUILDING_SHARED_LIBRARY"
)
# On Linux need to link to libdl
SET
(
OPENMM_BUILD_STATIC_LIB OFF CACHE BOOL
"Whether to build static OpenMM libraries"
)
FIND_LIBRARY
(
DL_LIBRARY dl
)
IF
(
OPENMM_BUILD_STATIC_LIB
)
IF
(
DL_LIBRARY
)
ADD_LIBRARY
(
${
STATIC_TARGET
}
STATIC
${
SOURCE_FILES
}
${
SOURCE_INCLUDE_FILES
}
${
API_ABS_INCLUDE_FILES
}
)
TARGET_LINK_LIBRARIES
(
${
SHARED_TARGET
}
${
DL_LIBRARY
}
)
SET_TARGET_PROPERTIES
(
${
STATIC_TARGET
}
PROPERTIES COMPILE_FLAGS
"-DOPENMM_USE_STATIC_LIBRARIES -DOPENMM_BUILDING_STATIC_LIBRARY -DLEPTON_USE_STATIC_LIBRARIES -DLEPTON_BUILDING_STATIC_LIBRARY -DOPENMMM_VALIDATE_BUILDING_STATIC_LIBRARY -DOPENMM_VALIDATE_BUILDING_STATIC_LIBRARY"
)
IF
(
OPENMM_BUILD_STATIC_LIB
)
ENDIF
(
OPENMM_BUILD_STATIC_LIB
)
TARGET_LINK_LIBRARIES
(
${
STATIC_TARGET
}
${
DL_LIBRARY
}
)
ENDIF
(
OPENMM_BUILD_STATIC_LIB
)
IF
(
OPENMM_BUILD_C_AND_FORTRAN_WRAPPERS
)
ENDIF
(
DL_LIBRARY
)
ADD_DEPENDENCIES
(
${
SHARED_TARGET
}
ApiWrappers
)
IF
(
WIN32
)
IF
(
OPENMM_BUILD_STATIC_LIB
)
MARK_AS_ADVANCED
(
DL_LIBRARY
)
ADD_DEPENDENCIES
(
${
STATIC_TARGET
}
ApiWrappers
)
ENDIF
(
WIN32
)
ENDIF
(
OPENMM_BUILD_STATIC_LIB
)
ENDIF
(
OPENMM_BUILD_C_AND_FORTRAN_WRAPPERS
)
ADD_SUBDIRECTORY
(
platforms/reference/tests
)
# On Linux need to link to libdl
# Which hardware platforms to build
FIND_LIBRARY
(
DL_LIBRARY dl
)
IF
(
DL_LIBRARY
)
# A bit of tedium because we are using custom FindCUDA files that happen to work...
TARGET_LINK_LIBRARIES
(
${
SHARED_TARGET
}
${
DL_LIBRARY
}
)
SET
(
FINDCUDA_DIR
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmake_modules/FindCUDA"
)
IF
(
OPENMM_BUILD_STATIC_LIB
)
SET
(
CUDA_BUILD_CUBIN OFF
)
TARGET_LINK_LIBRARIES
(
${
STATIC_TARGET
}
${
DL_LIBRARY
}
)
FIND_PACKAGE
(
CUDA QUIET
)
ENDIF
(
OPENMM_BUILD_STATIC_LIB
)
IF
(
CUDA_FOUND
)
ENDIF
(
DL_LIBRARY
)
IF
(
NOT CUDA_NVCC_FLAGS
)
IF
(
WIN32
)
SET
(
FLAGS
""
)
MARK_AS_ADVANCED
(
DL_LIBRARY
)
# Note that cmake will insert semicolons between these item automatically...
ENDIF
(
WIN32
)
SET
(
FLAGS
${
FLAGS
}
-gencode arch=compute_11,code=sm_11
)
SET
(
FLAGS
${
FLAGS
}
-gencode arch=compute_12,code=sm_12
)
ADD_SUBDIRECTORY
(
platforms/reference/tests
)
SET
(
FLAGS
${
FLAGS
}
-gencode arch=compute_13,code=sm_13
)
SET
(
FLAGS
${
FLAGS
}
-gencode arch=compute_20,code=sm_20
)
# Which hardware platforms to build
SET
(
FLAGS
${
FLAGS
}
-use_fast_math
)
IF
(
MSVC
)
# A bit of tedium because we are using custom FindCUDA files that happen to work...
# Unfortunately the variables CUDA_NVCC_FLAGS_RELEASE and CUDA_NVCC_FLAGS_DEBUG
SET
(
FINDCUDA_DIR
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmake_modules/FindCUDA"
)
# appear to be unused, at least in CMake 2.6
SET
(
CUDA_BUILD_CUBIN OFF
)
# Release /MD linkage
FIND_PACKAGE
(
CUDA QUIET
)
set
(
FLAGS
${
FLAGS
}
"-Xcompiler
\"
/MD
\"
-DOPENMMCUDA_BUILDING_SHARED_LIBRARY"
)
IF
(
CUDA_FOUND
)
ENDIF
(
MSVC
)
IF
(
NOT CUDA_NVCC_FLAGS
)
SET
(
CUDA_NVCC_FLAGS
"
${
FLAGS
}
"
SET
(
FLAGS
""
)
CACHE STRING
"Semicolon delimit multiple arguments"
)
# Note that cmake will insert semicolons between these item automatically...
ENDIF
(
NOT CUDA_NVCC_FLAGS
)
SET
(
FLAGS
${
FLAGS
}
-gencode arch=compute_11,code=sm_11
)
SET
(
OPENMM_BUILD_CUDA_LIB ON CACHE BOOL
"Build OpenMMCuda library for Nvidia GPUs"
)
SET
(
FLAGS
${
FLAGS
}
-gencode arch=compute_12,code=sm_12
)
SET
(
FLAGS
${
FLAGS
}
-gencode arch=compute_13,code=sm_13
)
# I wish I was not hardcoding /MD here
SET
(
FLAGS
${
FLAGS
}
-gencode arch=compute_20,code=sm_20
)
# Avoid strange windows link error with cuda free energy
SET
(
FLAGS
${
FLAGS
}
-use_fast_math
)
# plugin by specifying /MD to CUDA_NVCC_FLAGS
IF
(
MSVC
)
MARK_AS_ADVANCED
(
CLEAR CUDA_NVCC_FLAGS
)
# Unfortunately the variables CUDA_NVCC_FLAGS_RELEASE and CUDA_NVCC_FLAGS_DEBUG
IF
(
MSVC
)
# appear to be unused, at least in CMake 2.6
# Unfortunately the variables CUDA_NVCC_FLAGS_RELEASE and CUDA_NVCC_FLAGS_DEBUG
# Release /MD linkage
# appear to be unused, at least in CMake 2.6
set
(
FLAGS
${
FLAGS
}
"-Xcompiler
\"
/MD
\"
-DOPENMMCUDA_BUILDING_SHARED_LIBRARY"
)
# Release /MD linkage
ENDIF
(
MSVC
)
SET
(
HAS_NVCC_FLAG FALSE
)
SET
(
CUDA_NVCC_FLAGS
"
${
FLAGS
}
"
IF
(
CUDA_NVCC_FLAGS MATCHES
"-Xcompiler"
)
CACHE STRING
"Semicolon delimit multiple arguments"
)
SET
(
HAS_NVCC_FLAG TRUE
)
ENDIF
(
NOT CUDA_NVCC_FLAGS
)
ENDIF
(
CUDA_NVCC_FLAGS MATCHES
"-Xcompiler"
)
SET
(
OPENMM_BUILD_CUDA_LIB ON CACHE BOOL
"Build OpenMMCuda library for Nvidia GPUs"
)
IF
(
NOT HAS_NVCC_FLAG
)
set
(
new_flags
"-Xcompiler
\"
/MD
\"
-DOPENMMCUDA_BUILDING_SHARED_LIBRARY"
)
# I wish I was not hardcoding /MD here
if
(
CUDA_NVCC_FLAGS
)
# Avoid strange windows link error with cuda free energy
set
(
new_flags
"
${
CUDA_NVCC_FLAGS
}
;
${
new_flags
}
"
)
# plugin by specifying /MD to CUDA_NVCC_FLAGS
endif
(
CUDA_NVCC_FLAGS
)
MARK_AS_ADVANCED
(
CLEAR CUDA_NVCC_FLAGS
)
SET
(
CUDA_NVCC_FLAGS
"
${
new_flags
}
"
IF
(
MSVC
)
CACHE STRING
"Semicolon delimit multiple arguments"
FORCE
)
# Unfortunately the variables CUDA_NVCC_FLAGS_RELEASE and CUDA_NVCC_FLAGS_DEBUG
ENDIF
(
NOT HAS_NVCC_FLAG
)
# appear to be unused, at least in CMake 2.6
ENDIF
(
MSVC
)
# Release /MD linkage
ELSE
(
CUDA_FOUND
)
SET
(
HAS_NVCC_FLAG FALSE
)
SET
(
OPENMM_BUILD_CUDA_LIB OFF CACHE BOOL
"Build OpenMMCuda library for Nvidia GPUs"
)
IF
(
CUDA_NVCC_FLAGS MATCHES
"-Xcompiler"
)
ENDIF
(
CUDA_FOUND
)
SET
(
HAS_NVCC_FLAG TRUE
)
IF
(
OPENMM_BUILD_CUDA_LIB
)
ENDIF
(
CUDA_NVCC_FLAGS MATCHES
"-Xcompiler"
)
ADD_SUBDIRECTORY
(
platforms/cuda
)
IF
(
NOT HAS_NVCC_FLAG
)
ENDIF
(
OPENMM_BUILD_CUDA_LIB
)
set
(
new_flags
"-Xcompiler
\"
/MD
\"
-DOPENMMCUDA_BUILDING_SHARED_LIBRARY"
)
MARK_AS_ADVANCED
(
CUDA_VERBOSE_BUILD
)
if
(
CUDA_NVCC_FLAGS
)
MARK_AS_ADVANCED
(
CUDA_BUILD_CUBIN
)
set
(
new_flags
"
${
CUDA_NVCC_FLAGS
}
;
${
new_flags
}
"
)
MARK_AS_ADVANCED
(
CUDA_BUILD_EMULATION
)
endif
(
CUDA_NVCC_FLAGS
)
SET
(
CUDA_NVCC_FLAGS
"
${
new_flags
}
"
FIND_PACKAGE
(
OpenCL QUIET
)
CACHE STRING
"Semicolon delimit multiple arguments"
FORCE
)
# Plus the tesla/linux is taking too long on the tests
ENDIF
(
NOT HAS_NVCC_FLAG
)
IF
(
OPENCL_FOUND
)
ENDIF
(
MSVC
)
SET
(
OPENMM_BUILD_OPENCL_LIB ON CACHE BOOL
"Build OpenMMOpenCL library"
)
ELSE
(
CUDA_FOUND
)
ELSE
(
OPENCL_FOUND
)
SET
(
OPENMM_BUILD_CUDA_LIB OFF CACHE BOOL
"Build OpenMMCuda library for Nvidia GPUs"
)
SET
(
OPENMM_BUILD_OPENCL_LIB OFF CACHE BOOL
"Build OpenMMOpenCL library"
)
ENDIF
(
CUDA_FOUND
)
ENDIF
(
OPENCL_FOUND
)
IF
(
OPENMM_BUILD_CUDA_LIB
)
IF
(
OPENMM_BUILD_OPENCL_LIB
)
ADD_SUBDIRECTORY
(
platforms/cuda
)
ADD_SUBDIRECTORY
(
platforms/opencl
)
ENDIF
(
OPENMM_BUILD_CUDA_LIB
)
ENDIF
(
OPENMM_BUILD_OPENCL_LIB
)
MARK_AS_ADVANCED
(
CUDA_VERBOSE_BUILD
)
MARK_AS_ADVANCED
(
CUDA_BUILD_CUBIN
)
# FreeEnergy plugin
MARK_AS_ADVANCED
(
CUDA_BUILD_EMULATION
)
SET
(
OPENMM_BUILD_FREE_ENERGY_PLUGIN ON CACHE BOOL
"Build FreeEnergy plugin"
)
FIND_PACKAGE
(
OpenCL QUIET
)
SET
(
OPENMM_BUILD_FREE_ENERGY_PATH
)
# Plus the tesla/linux is taking too long on the tests
IF
(
OPENMM_BUILD_FREE_ENERGY_PLUGIN
)
IF
(
OPENCL_FOUND
)
SET
(
OPENMM_BUILD_FREE_ENERGY_PATH
${
CMAKE_CURRENT_SOURCE_DIR
}
/plugins/freeEnergy
)
SET
(
OPENMM_BUILD_OPENCL_LIB ON CACHE BOOL
"Build OpenMMOpenCL library"
)
# ADD_DEFINITIONS(-DINCLUDE_FREE_ENERGY_PLUGIN)
ELSE
(
OPENCL_FOUND
)
ADD_SUBDIRECTORY
(
plugins/freeEnergy
)
SET
(
OPENMM_BUILD_OPENCL_LIB OFF CACHE BOOL
"Build OpenMMOpenCL library"
)
ENDIF
(
OPENMM_BUILD_FREE_ENERGY_PLUGIN
)
ENDIF
(
OPENCL_FOUND
)
IF
(
OPENMM_BUILD_OPENCL_LIB
)
# Amoeba plugin
ADD_SUBDIRECTORY
(
platforms/opencl
)
ENDIF
(
OPENMM_BUILD_OPENCL_LIB
)
SET
(
OPENMM_BUILD_AMOEBA_PLUGIN ON CACHE BOOL
"Build Amoeba plugin"
)
SET
(
OPENMM_BUILD_AMOEBA_PATH
)
# FreeEnergy plugin
IF
(
OPENMM_BUILD_AMOEBA_PLUGIN
)
SET
(
OPENMM_BUILD_AMOEBA_PATH
${
CMAKE_CURRENT_SOURCE_DIR
}
/plugins/amoeba
)
SET
(
OPENMM_BUILD_FREE_ENERGY_PLUGIN ON CACHE BOOL
"Build FreeEnergy plugin"
)
ADD_SUBDIRECTORY
(
plugins/amoeba
)
SET
(
OPENMM_BUILD_FREE_ENERGY_PATH
)
ENDIF
(
OPENMM_BUILD_AMOEBA_PLUGIN
)
IF
(
OPENMM_BUILD_FREE_ENERGY_PLUGIN
)
SET
(
OPENMM_BUILD_FREE_ENERGY_PATH
${
CMAKE_CURRENT_SOURCE_DIR
}
/plugins/freeEnergy
)
INSTALL_TARGETS
(
/lib RUNTIME_DIRECTORY /lib
${
SHARED_TARGET
}
)
# ADD_DEFINITIONS(-DINCLUDE_FREE_ENERGY_PLUGIN)
IF
(
OPENMM_BUILD_STATIC_LIB
)
ADD_SUBDIRECTORY
(
plugins/freeEnergy
)
INSTALL_TARGETS
(
/lib RUNTIME_DIRECTORY /lib
${
STATIC_TARGET
}
)
ENDIF
(
OPENMM_BUILD_FREE_ENERGY_PLUGIN
)
ENDIF
(
OPENMM_BUILD_STATIC_LIB
)
FILE
(
GLOB CORE_HEADERS include/*.h */include/*.h
)
# Amoeba plugin
FILE
(
GLOB TOP_HEADERS include/openmm/*.h */include/openmm/*.h
)
FILE
(
GLOB INTERNAL_HEADERS include/openmm/internal/*.h */include/openmm/internal/*.h
)
SET
(
OPENMM_BUILD_AMOEBA_PLUGIN ON CACHE BOOL
"Build Amoeba plugin"
)
INSTALL_FILES
(
/include FILES
${
CORE_HEADERS
}
)
SET
(
OPENMM_BUILD_AMOEBA_PATH
)
INSTALL_FILES
(
/include/openmm FILES
${
TOP_HEADERS
}
)
IF
(
OPENMM_BUILD_AMOEBA_PLUGIN
)
INSTALL_FILES
(
/include/openmm/internal FILES
${
INTERNAL_HEADERS
}
)
SET
(
OPENMM_BUILD_AMOEBA_PATH
${
CMAKE_CURRENT_SOURCE_DIR
}
/plugins/amoeba
)
ADD_SUBDIRECTORY
(
plugins/amoeba
)
# Serialization support
ENDIF
(
OPENMM_BUILD_AMOEBA_PLUGIN
)
SET
(
OPENMM_BUILD_SERIALIZATION_SUPPORT ON CACHE BOOL
"Whether to build the serialization support library"
)
INSTALL_TARGETS
(
/lib RUNTIME_DIRECTORY /lib
${
SHARED_TARGET
}
)
IF
(
OPENMM_BUILD_SERIALIZATION_SUPPORT
)
IF
(
OPENMM_BUILD_STATIC_LIB
)
ADD_SUBDIRECTORY
(
serialization
)
INSTALL_TARGETS
(
/lib RUNTIME_DIRECTORY /lib
${
STATIC_TARGET
}
)
ENDIF
(
OPENMM_BUILD_SERIALIZATION_SUPPORT
)
ENDIF
(
OPENMM_BUILD_STATIC_LIB
)
FILE
(
GLOB CORE_HEADERS include/*.h */include/*.h
)
# Python wrappers
FILE
(
GLOB TOP_HEADERS include/openmm/*.h */include/openmm/*.h
)
FILE
(
GLOB INTERNAL_HEADERS include/openmm/internal/*.h */include/openmm/internal/*.h
)
SET
(
OPENMM_BUILD_PYTHON_WRAPPERS OFF CACHE BOOL
"Build wrappers for Python"
)
INSTALL_FILES
(
/include FILES
${
CORE_HEADERS
}
)
IF
(
OPENMM_BUILD_PYTHON_WRAPPERS
)
INSTALL_FILES
(
/include/openmm FILES
${
TOP_HEADERS
}
)
IF
(
NOT OPENMM_BUILD_SERIALIZATION_SUPPORT
)
INSTALL_FILES
(
/include/openmm/internal FILES
${
INTERNAL_HEADERS
}
)
MESSAGE
(
SEND_ERROR
"The Python wrappers require that serialization support be built."
)
ENDIF
(
NOT OPENMM_BUILD_SERIALIZATION_SUPPORT
)
# Serialization support
IF
(
NOT OPENMM_BUILD_FREE_ENERGY_PLUGIN
)
MESSAGE
(
SEND_ERROR
"The Python wrappers require that the free energy plugin be built."
)
SET
(
OPENMM_BUILD_SERIALIZATION_SUPPORT ON CACHE BOOL
"Whether to build the serialization support library"
)
ENDIF
(
NOT OPENMM_BUILD_FREE_ENERGY_PLUGIN
)
IF
(
OPENMM_BUILD_SERIALIZATION_SUPPORT
)
IF
(
NOT OPENMM_BUILD_AMOEBA_PLUGIN
)
ADD_SUBDIRECTORY
(
serialization
)
MESSAGE
(
SEND_ERROR
"The Python wrappers require that the AMOEBA plugin be built."
)
ENDIF
(
OPENMM_BUILD_SERIALIZATION_SUPPORT
)
ENDIF
(
NOT OPENMM_BUILD_AMOEBA_PLUGIN
)
ADD_SUBDIRECTORY
(
wrappers/python
)
# Python wrappers
ENDIF
(
OPENMM_BUILD_PYTHON_WRAPPERS
)
SET
(
OPENMM_BUILD_PYTHON_WRAPPERS OFF CACHE BOOL
"Build wrappers for Python"
)
IF
(
OPENMM_BUILD_PYTHON_WRAPPERS
)
#
IF
(
NOT OPENMM_BUILD_SERIALIZATION_SUPPORT
)
# Allow automated build and dashboard.
MESSAGE
(
SEND_ERROR
"The Python wrappers require that serialization support be built."
)
#
ENDIF
(
NOT OPENMM_BUILD_SERIALIZATION_SUPPORT
)
# redundant INCLUDE(Dart) statement
IF
(
NOT OPENMM_BUILD_FREE_ENERGY_PLUGIN
)
# INCLUDE (Dart)
MESSAGE
(
SEND_ERROR
"The Python wrappers require that the free energy plugin be built."
)
ENDIF
(
NOT OPENMM_BUILD_FREE_ENERGY_PLUGIN
)
#IF (UNIX AND NOT CYGWIN AND NOT APPLE)
IF
(
NOT OPENMM_BUILD_AMOEBA_PLUGIN
)
# IF (NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE MATCHES Debug)
MESSAGE
(
SEND_ERROR
"The Python wrappers require that the AMOEBA plugin be built."
)
# ADD_DEFINITIONS(-fprofile-arcs -ftest-coverage)
ENDIF
(
NOT OPENMM_BUILD_AMOEBA_PLUGIN
)
# LINK_LIBRARIES(gcov)
ADD_SUBDIRECTORY
(
wrappers/python
)
# ENDIF (NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE MATCHES Debug)
ENDIF
(
OPENMM_BUILD_PYTHON_WRAPPERS
)
#ENDIF (UNIX AND NOT CYGWIN AND NOT APPLE)
#
#
# Allow automated build and dashboard.
# Testing
#
#
# redundant INCLUDE(Dart) statement
# INCLUDE (Dart)
ENABLE_TESTING
()
#IF (UNIX AND NOT CYGWIN AND NOT APPLE)
IF
(
EXECUTABLE_OUTPUT_PATH
)
# IF (NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE MATCHES Debug)
SET
(
TEST_PATH
${
EXECUTABLE_OUTPUT_PATH
}
)
# ADD_DEFINITIONS(-fprofile-arcs -ftest-coverage)
ELSE
(
EXECUTABLE_OUTPUT_PATH
)
# LINK_LIBRARIES(gcov)
SET
(
TEST_PATH .
)
# ENDIF (NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE MATCHES Debug)
ENDIF
(
EXECUTABLE_OUTPUT_PATH
)
#ENDIF (UNIX AND NOT CYGWIN AND NOT APPLE)
# Build and install documentation
#
find_package
(
Doxygen QUIET
)
# Testing
mark_as_advanced
(
CLEAR DOXYGEN_EXECUTABLE
)
#
IF
(
DOXYGEN_EXECUTABLE
)
SET
(
DOXY_CONFIG
"
${
CMAKE_CURRENT_BINARY_DIR
}
/Doxyfile"
)
ENABLE_TESTING
()
CONFIGURE_FILE
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/docs/Doxyfile.in
${
DOXY_CONFIG
}
IF
(
EXECUTABLE_OUTPUT_PATH
)
@ONLY
)
SET
(
TEST_PATH
${
EXECUTABLE_OUTPUT_PATH
}
)
FILE
(
GLOB_RECURSE OPENMM_INCLUDES
"openmm/include/*.h"
)
ELSE
(
EXECUTABLE_OUTPUT_PATH
)
FILE
(
GLOB_RECURSE OLLA_INCLUDES
"olla/include/*.h"
)
SET
(
TEST_PATH .
)
ADD_CUSTOM_COMMAND
(
ENDIF
(
EXECUTABLE_OUTPUT_PATH
)
OUTPUT
"
${
CMAKE_CURRENT_BINARY_DIR
}
/html/index.html"
COMMAND
${
DOXYGEN_EXECUTABLE
}
${
DOXY_CONFIG
}
# Build and install documentation
DEPENDS
${
OPENMM_INCLUDES
}
${
OLLA_INCLUDES
}
WORKING_DIRECTORY
"
${
CMAKE_CURRENT_BINARY_DIR
}
"
find_package
(
Doxygen QUIET
)
COMMENT
"Generating API documentation using Doxygen"
)
mark_as_advanced
(
CLEAR DOXYGEN_EXECUTABLE
)
ADD_CUSTOM_TARGET
(
DoxygenApiDocs
IF
(
DOXYGEN_EXECUTABLE
)
DEPENDS
"
${
CMAKE_CURRENT_BINARY_DIR
}
/html/index.html"
SET
(
DOXY_CONFIG
"
${
CMAKE_CURRENT_BINARY_DIR
}
/Doxyfile"
)
COMMENT
"Generating API documentation using Doxygen"
CONFIGURE_FILE
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/docs/Doxyfile.in
SOURCES
${
DOXY_CONFIG
}
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/docs/Doxyfile.in"
@ONLY
)
${
OPENMM_INCLUDES
}
FILE
(
GLOB_RECURSE OPENMM_INCLUDES
"openmm/include/*.h"
)
${
OLLA_INCLUDES
}
FILE
(
GLOB_RECURSE OLLA_INCLUDES
"olla/include/*.h"
)
)
ADD_CUSTOM_COMMAND
(
FILE
(
MAKE_DIRECTORY
"
${
PROJECT_BINARY_DIR
}
/html/"
)
OUTPUT
"
${
CMAKE_CURRENT_BINARY_DIR
}
/html/index.html"
INSTALL
(
DIRECTORY
"
${
PROJECT_BINARY_DIR
}
/html/"
COMMAND
${
DOXYGEN_EXECUTABLE
}
${
DOXY_CONFIG
}
DESTINATION
"docs/api/"
)
DEPENDS
${
OPENMM_INCLUDES
}
${
OLLA_INCLUDES
}
INSTALL
(
FILES
"docs/API Reference.html"
WORKING_DIRECTORY
"
${
CMAKE_CURRENT_BINARY_DIR
}
"
DESTINATION
"docs/"
)
COMMENT
"Generating API documentation using Doxygen"
)
set
(
OPENMM_GENERATE_API_DOCS OFF CACHE BOOL
"Whether to create API documentation using Doxygen"
)
ADD_CUSTOM_TARGET
(
DoxygenApiDocs
if
(
OPENMM_GENERATE_API_DOCS
)
DEPENDS
"
${
CMAKE_CURRENT_BINARY_DIR
}
/html/index.html"
ADD_CUSTOM_TARGET
(
GenerateDoxygenApiDocs ALL
COMMENT
"Generating API documentation using Doxygen"
DEPENDS
"
${
CMAKE_CURRENT_BINARY_DIR
}
/html/index.html"
SOURCES
COMMENT
"Generating API documentation using Doxygen"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/docs/Doxyfile.in"
SOURCES
${
OPENMM_INCLUDES
}
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/docs/Doxyfile.in"
${
OLLA_INCLUDES
}
${
OPENMM_INCLUDES
}
)
${
OLLA_INCLUDES
}
FILE
(
MAKE_DIRECTORY
"
${
PROJECT_BINARY_DIR
}
/html/"
)
)
INSTALL
(
DIRECTORY
"
${
PROJECT_BINARY_DIR
}
/html/"
endif
(
OPENMM_GENERATE_API_DOCS
)
DESTINATION
"docs/api/"
)
ENDIF
(
DOXYGEN_EXECUTABLE
)
INSTALL
(
FILES
"docs/API Reference.html"
DESTINATION
"docs/"
)
install
(
FILES docs/UsersGuide/OpenMMUsersGuide.pdf
set
(
OPENMM_GENERATE_API_DOCS OFF CACHE BOOL
"Whether to create API documentation using Doxygen"
)
DESTINATION docs/
)
if
(
OPENMM_GENERATE_API_DOCS
)
ADD_CUSTOM_TARGET
(
GenerateDoxygenApiDocs ALL
FILE
(
GLOB LICENSE_FILES
"docs/licenses/*.txt"
)
DEPENDS
"
${
CMAKE_CURRENT_BINARY_DIR
}
/html/index.html"
install
(
FILES
${
LICENSE_FILES
}
COMMENT
"Generating API documentation using Doxygen"
DESTINATION licenses/
)
SOURCES
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/docs/Doxyfile.in"
ADD_SUBDIRECTORY
(
tests
)
${
OPENMM_INCLUDES
}
ADD_SUBDIRECTORY
(
examples
)
${
OLLA_INCLUDES
}
)
ENDIF
(
NOT cmv EQUAL
"2.4"
)
# This whole file...
endif
(
OPENMM_GENERATE_API_DOCS
)
ENDIF
(
DOXYGEN_EXECUTABLE
)
install
(
FILES docs/UsersGuide/OpenMMUsersGuide.pdf
DESTINATION docs/
)
FILE
(
GLOB LICENSE_FILES
"docs/licenses/*.txt"
)
install
(
FILES
${
LICENSE_FILES
}
DESTINATION licenses/
)
ADD_SUBDIRECTORY
(
tests
)
ADD_SUBDIRECTORY
(
examples
)
ENDIF
(
NOT cmv EQUAL
"2.4"
)
# This whole file...
libraries/pthreads/include/pthread.h
0 → 100644
View file @
cb75edd4
/* This is an implementation of the threads API of POSIX 1003.1-2001.
*
* --------------------------------------------------------------------------
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
* Copyright(C) 1999,2005 Pthreads-win32 contributors
*
* Contact Email: rpj@callisto.canberra.edu.au
*
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
* http://sources.redhat.com/pthreads-win32/contributors.html
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library in the file COPYING.LIB;
* if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined( PTHREAD_H )
#define PTHREAD_H
/*
* See the README file for an explanation of the pthreads-win32 version
* numbering scheme and how the DLL is named etc.
*/
#define PTW32_VERSION 2,8,0,0
#define PTW32_VERSION_STRING "2, 8, 0, 0\0"
/* There are three implementations of cancel cleanup.
* Note that pthread.h is included in both application
* compilation units and also internally for the library.
* The code here and within the library aims to work
* for all reasonable combinations of environments.
*
* The three implementations are:
*
* WIN32 SEH
* C
* C++
*
* Please note that exiting a push/pop block via
* "return", "exit", "break", or "continue" will
* lead to different behaviour amongst applications
* depending upon whether the library was built
* using SEH, C++, or C. For example, a library built
* with SEH will call the cleanup routine, while both
* C++ and C built versions will not.
*/
/*
* Define defaults for cleanup code.
* Note: Unless the build explicitly defines one of the following, then
* we default to standard C style cleanup. This style uses setjmp/longjmp
* in the cancelation and thread exit implementations and therefore won't
* do stack unwinding if linked to applications that have it (e.g.
* C++ apps). This is currently consistent with most/all commercial Unix
* POSIX threads implementations.
*/
#if !defined( __CLEANUP_SEH ) && !defined( __CLEANUP_CXX ) && !defined( __CLEANUP_C )
# define __CLEANUP_C
#endif
#if defined( __CLEANUP_SEH ) && ( !defined( _MSC_VER ) && !defined(PTW32_RC_MSC))
#error ERROR [__FILE__, line __LINE__]: SEH is not supported for this compiler.
#endif
/*
* Stop here if we are being included by the resource compiler.
*/
#ifndef RC_INVOKED
#undef PTW32_LEVEL
#if defined(_POSIX_SOURCE)
#define PTW32_LEVEL 0
/* Early POSIX */
#endif
#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309
#undef PTW32_LEVEL
#define PTW32_LEVEL 1
/* Include 1b, 1c and 1d */
#endif
#if defined(INCLUDE_NP)
#undef PTW32_LEVEL
#define PTW32_LEVEL 2
/* Include Non-Portable extensions */
#endif
#define PTW32_LEVEL_MAX 3
#if !defined(PTW32_LEVEL)
#define PTW32_LEVEL PTW32_LEVEL_MAX
/* Include everything */
#endif
#ifdef _UWIN
# define HAVE_STRUCT_TIMESPEC 1
# define HAVE_SIGNAL_H 1
# undef HAVE_CONFIG_H
# pragma comment(lib, "pthread")
#endif
/*
* -------------------------------------------------------------
*
*
* Module: pthread.h
*
* Purpose:
* Provides an implementation of PThreads based upon the
* standard:
*
* POSIX 1003.1-2001
* and
* The Single Unix Specification version 3
*
* (these two are equivalent)
*
* in order to enhance code portability between Windows,
* various commercial Unix implementations, and Linux.
*
* See the ANNOUNCE file for a full list of conforming
* routines and defined constants, and a list of missing
* routines and constants not defined in this implementation.
*
* Authors:
* There have been many contributors to this library.
* The initial implementation was contributed by
* John Bossom, and several others have provided major
* sections or revisions of parts of the implementation.
* Often significant effort has been contributed to
* find and fix important bugs and other problems to
* improve the reliability of the library, which sometimes
* is not reflected in the amount of code which changed as
* result.
* As much as possible, the contributors are acknowledged
* in the ChangeLog file in the source code distribution
* where their changes are noted in detail.
*
* Contributors are listed in the CONTRIBUTORS file.
*
* As usual, all bouquets go to the contributors, and all
* brickbats go to the project maintainer.
*
* Maintainer:
* The code base for this project is coordinated and
* eventually pre-tested, packaged, and made available by
*
* Ross Johnson <rpj@callisto.canberra.edu.au>
*
* QA Testers:
* Ultimately, the library is tested in the real world by
* a host of competent and demanding scientists and
* engineers who report bugs and/or provide solutions
* which are then fixed or incorporated into subsequent
* versions of the library. Each time a bug is fixed, a
* test case is written to prove the fix and ensure
* that later changes to the code don't reintroduce the
* same error. The number of test cases is slowly growing
* and therefore so is the code reliability.
*
* Compliance:
* See the file ANNOUNCE for the list of implemented
* and not-implemented routines and defined options.
* Of course, these are all defined is this file as well.
*
* Web site:
* The source code and other information about this library
* are available from
*
* http://sources.redhat.com/pthreads-win32/
*
* -------------------------------------------------------------
*/
/* Try to avoid including windows.h */
#if defined(__MINGW32__) && defined(__cplusplus)
#define PTW32_INCLUDE_WINDOWS_H
#endif
#ifdef PTW32_INCLUDE_WINDOWS_H
#include <windows.h>
#endif
#if defined(_MSC_VER) && _MSC_VER < 1300 || defined(__DMC__)
/*
* VC++6.0 or early compiler's header has no DWORD_PTR type.
*/
typedef
unsigned
long
DWORD_PTR
;
#endif
/*
* -----------------
* autoconf switches
* -----------------
*/
#if HAVE_CONFIG_H
#include "config.h"
#endif
/* HAVE_CONFIG_H */
#ifndef NEED_FTIME
#include <time.h>
#else
/* NEED_FTIME */
/* use native WIN32 time API */
#endif
/* NEED_FTIME */
#if HAVE_SIGNAL_H
#include <signal.h>
#endif
/* HAVE_SIGNAL_H */
#include <setjmp.h>
#include <limits.h>
/*
* Boolean values to make us independent of system includes.
*/
enum
{
PTW32_FALSE
=
0
,
PTW32_TRUE
=
(
!
PTW32_FALSE
)
};
/*
* This is a duplicate of what is in the autoconf config.h,
* which is only used when building the pthread-win32 libraries.
*/
#ifndef PTW32_CONFIG_H
# if defined(WINCE)
# define NEED_ERRNO
# define NEED_SEM
# endif
# if defined(_UWIN) || defined(__MINGW32__)
# define HAVE_MODE_T
# endif
#endif
/*
*
*/
#if PTW32_LEVEL >= PTW32_LEVEL_MAX
#ifdef NEED_ERRNO
#include "need_errno.h"
#else
#include <errno.h>
#endif
#endif
/* PTW32_LEVEL >= PTW32_LEVEL_MAX */
/*
* Several systems don't define some error numbers.
*/
#ifndef ENOTSUP
# define ENOTSUP 48
/* This is the value in Solaris. */
#endif
#ifndef ETIMEDOUT
# define ETIMEDOUT 10060
/* This is the value in winsock.h. */
#endif
#ifndef ENOSYS
# define ENOSYS 140
/* Semi-arbitrary value */
#endif
#ifndef EDEADLK
# ifdef EDEADLOCK
# define EDEADLK EDEADLOCK
# else
# define EDEADLK 36
/* This is the value in MSVC. */
# endif
#endif
#include <sched.h>
/*
* To avoid including windows.h we define only those things that we
* actually need from it.
*/
#ifndef PTW32_INCLUDE_WINDOWS_H
#ifndef HANDLE
# define PTW32__HANDLE_DEF
# define HANDLE void *
#endif
#ifndef DWORD
# define PTW32__DWORD_DEF
# define DWORD unsigned long
#endif
#endif
#ifndef HAVE_STRUCT_TIMESPEC
#define HAVE_STRUCT_TIMESPEC 1
struct
timespec
{
long
tv_sec
;
long
tv_nsec
;
};
#endif
/* HAVE_STRUCT_TIMESPEC */
#ifndef SIG_BLOCK
#define SIG_BLOCK 0
#endif
/* SIG_BLOCK */
#ifndef SIG_UNBLOCK
#define SIG_UNBLOCK 1
#endif
/* SIG_UNBLOCK */
#ifndef SIG_SETMASK
#define SIG_SETMASK 2
#endif
/* SIG_SETMASK */
#ifdef __cplusplus
extern
"C"
{
#endif
/* __cplusplus */
/*
* -------------------------------------------------------------
*
* POSIX 1003.1-2001 Options
* =========================
*
* Options are normally set in <unistd.h>, which is not provided
* with pthreads-win32.
*
* For conformance with the Single Unix Specification (version 3), all of the
* options below are defined, and have a value of either -1 (not supported)
* or 200112L (supported).
*
* These options can neither be left undefined nor have a value of 0, because
* either indicates that sysconf(), which is not implemented, may be used at
* runtime to check the status of the option.
*
* _POSIX_THREADS (== 200112L)
* If == 200112L, you can use threads
*
* _POSIX_THREAD_ATTR_STACKSIZE (== 200112L)
* If == 200112L, you can control the size of a thread's
* stack
* pthread_attr_getstacksize
* pthread_attr_setstacksize
*
* _POSIX_THREAD_ATTR_STACKADDR (== -1)
* If == 200112L, you can allocate and control a thread's
* stack. If not supported, the following functions
* will return ENOSYS, indicating they are not
* supported:
* pthread_attr_getstackaddr
* pthread_attr_setstackaddr
*
* _POSIX_THREAD_PRIORITY_SCHEDULING (== -1)
* If == 200112L, you can use realtime scheduling.
* This option indicates that the behaviour of some
* implemented functions conforms to the additional TPS
* requirements in the standard. E.g. rwlocks favour
* writers over readers when threads have equal priority.
*
* _POSIX_THREAD_PRIO_INHERIT (== -1)
* If == 200112L, you can create priority inheritance
* mutexes.
* pthread_mutexattr_getprotocol +
* pthread_mutexattr_setprotocol +
*
* _POSIX_THREAD_PRIO_PROTECT (== -1)
* If == 200112L, you can create priority ceiling mutexes
* Indicates the availability of:
* pthread_mutex_getprioceiling
* pthread_mutex_setprioceiling
* pthread_mutexattr_getprioceiling
* pthread_mutexattr_getprotocol +
* pthread_mutexattr_setprioceiling
* pthread_mutexattr_setprotocol +
*
* _POSIX_THREAD_PROCESS_SHARED (== -1)
* If set, you can create mutexes and condition
* variables that can be shared with another
* process.If set, indicates the availability
* of:
* pthread_mutexattr_getpshared
* pthread_mutexattr_setpshared
* pthread_condattr_getpshared
* pthread_condattr_setpshared
*
* _POSIX_THREAD_SAFE_FUNCTIONS (== 200112L)
* If == 200112L you can use the special *_r library
* functions that provide thread-safe behaviour
*
* _POSIX_READER_WRITER_LOCKS (== 200112L)
* If == 200112L, you can use read/write locks
*
* _POSIX_SPIN_LOCKS (== 200112L)
* If == 200112L, you can use spin locks
*
* _POSIX_BARRIERS (== 200112L)
* If == 200112L, you can use barriers
*
* + These functions provide both 'inherit' and/or
* 'protect' protocol, based upon these macro
* settings.
*
* -------------------------------------------------------------
*/
/*
* POSIX Options
*/
#undef _POSIX_THREADS
#define _POSIX_THREADS 200112L
#undef _POSIX_READER_WRITER_LOCKS
#define _POSIX_READER_WRITER_LOCKS 200112L
#undef _POSIX_SPIN_LOCKS
#define _POSIX_SPIN_LOCKS 200112L
#undef _POSIX_BARRIERS
#define _POSIX_BARRIERS 200112L
#undef _POSIX_THREAD_SAFE_FUNCTIONS
#define _POSIX_THREAD_SAFE_FUNCTIONS 200112L
#undef _POSIX_THREAD_ATTR_STACKSIZE
#define _POSIX_THREAD_ATTR_STACKSIZE 200112L
/*
* The following options are not supported
*/
#undef _POSIX_THREAD_ATTR_STACKADDR
#define _POSIX_THREAD_ATTR_STACKADDR -1
#undef _POSIX_THREAD_PRIO_INHERIT
#define _POSIX_THREAD_PRIO_INHERIT -1
#undef _POSIX_THREAD_PRIO_PROTECT
#define _POSIX_THREAD_PRIO_PROTECT -1
/* TPS is not fully supported. */
#undef _POSIX_THREAD_PRIORITY_SCHEDULING
#define _POSIX_THREAD_PRIORITY_SCHEDULING -1
#undef _POSIX_THREAD_PROCESS_SHARED
#define _POSIX_THREAD_PROCESS_SHARED -1
/*
* POSIX 1003.1-2001 Limits
* ===========================
*
* These limits are normally set in <limits.h>, which is not provided with
* pthreads-win32.
*
* PTHREAD_DESTRUCTOR_ITERATIONS
* Maximum number of attempts to destroy
* a thread's thread-specific data on
* termination (must be at least 4)
*
* PTHREAD_KEYS_MAX
* Maximum number of thread-specific data keys
* available per process (must be at least 128)
*
* PTHREAD_STACK_MIN
* Minimum supported stack size for a thread
*
* PTHREAD_THREADS_MAX
* Maximum number of threads supported per
* process (must be at least 64).
*
* SEM_NSEMS_MAX
* The maximum number of semaphores a process can have.
* (must be at least 256)
*
* SEM_VALUE_MAX
* The maximum value a semaphore can have.
* (must be at least 32767)
*
*/
#undef _POSIX_THREAD_DESTRUCTOR_ITERATIONS
#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
#undef PTHREAD_DESTRUCTOR_ITERATIONS
#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
#undef _POSIX_THREAD_KEYS_MAX
#define _POSIX_THREAD_KEYS_MAX 128
#undef PTHREAD_KEYS_MAX
#define PTHREAD_KEYS_MAX _POSIX_THREAD_KEYS_MAX
#undef PTHREAD_STACK_MIN
#define PTHREAD_STACK_MIN 0
#undef _POSIX_THREAD_THREADS_MAX
#define _POSIX_THREAD_THREADS_MAX 64
/* Arbitrary value */
#undef PTHREAD_THREADS_MAX
#define PTHREAD_THREADS_MAX 2019
#undef _POSIX_SEM_NSEMS_MAX
#define _POSIX_SEM_NSEMS_MAX 256
/* Arbitrary value */
#undef SEM_NSEMS_MAX
#define SEM_NSEMS_MAX 1024
#undef _POSIX_SEM_VALUE_MAX
#define _POSIX_SEM_VALUE_MAX 32767
#undef SEM_VALUE_MAX
#define SEM_VALUE_MAX INT_MAX
#if __GNUC__ && ! defined (__declspec)
# error Please upgrade your GNU compiler to one that supports __declspec.
#endif
/*
* When building the DLL code, you should define PTW32_BUILD so that
* the variables/functions are exported correctly. When using the DLL,
* do NOT define PTW32_BUILD, and then the variables/functions will
* be imported correctly.
*/
#ifndef PTW32_STATIC_LIB
# ifdef PTW32_BUILD
# define PTW32_DLLPORT __declspec (dllexport)
# else
# define PTW32_DLLPORT __declspec (dllimport)
# endif
#else
# define PTW32_DLLPORT
#endif
/*
* The Open Watcom C/C++ compiler uses a non-standard calling convention
* that passes function args in registers unless __cdecl is explicitly specified
* in exposed function prototypes.
*
* We force all calls to cdecl even though this could slow Watcom code down
* slightly. If you know that the Watcom compiler will be used to build both
* the DLL and application, then you can probably define this as a null string.
* Remember that pthread.h (this file) is used for both the DLL and application builds.
*/
#define PTW32_CDECL __cdecl
#if defined(_UWIN) && PTW32_LEVEL >= PTW32_LEVEL_MAX
# include <sys/types.h>
#else
/*
* Generic handle type - intended to extend uniqueness beyond
* that available with a simple pointer. It should scale for either
* IA-32 or IA-64.
*/
typedef
struct
{
void
*
p
;
/* Pointer to actual object */
unsigned
int
x
;
/* Extra information - reuse count etc */
}
ptw32_handle_t
;
typedef
ptw32_handle_t
pthread_t
;
typedef
struct
pthread_attr_t_
*
pthread_attr_t
;
typedef
struct
pthread_once_t_
pthread_once_t
;
typedef
struct
pthread_key_t_
*
pthread_key_t
;
typedef
struct
pthread_mutex_t_
*
pthread_mutex_t
;
typedef
struct
pthread_mutexattr_t_
*
pthread_mutexattr_t
;
typedef
struct
pthread_cond_t_
*
pthread_cond_t
;
typedef
struct
pthread_condattr_t_
*
pthread_condattr_t
;
#endif
typedef
struct
pthread_rwlock_t_
*
pthread_rwlock_t
;
typedef
struct
pthread_rwlockattr_t_
*
pthread_rwlockattr_t
;
typedef
struct
pthread_spinlock_t_
*
pthread_spinlock_t
;
typedef
struct
pthread_barrier_t_
*
pthread_barrier_t
;
typedef
struct
pthread_barrierattr_t_
*
pthread_barrierattr_t
;
/*
* ====================
* ====================
* POSIX Threads
* ====================
* ====================
*/
enum
{
/*
* pthread_attr_{get,set}detachstate
*/
PTHREAD_CREATE_JOINABLE
=
0
,
/* Default */
PTHREAD_CREATE_DETACHED
=
1
,
/*
* pthread_attr_{get,set}inheritsched
*/
PTHREAD_INHERIT_SCHED
=
0
,
PTHREAD_EXPLICIT_SCHED
=
1
,
/* Default */
/*
* pthread_{get,set}scope
*/
PTHREAD_SCOPE_PROCESS
=
0
,
PTHREAD_SCOPE_SYSTEM
=
1
,
/* Default */
/*
* pthread_setcancelstate paramters
*/
PTHREAD_CANCEL_ENABLE
=
0
,
/* Default */
PTHREAD_CANCEL_DISABLE
=
1
,
/*
* pthread_setcanceltype parameters
*/
PTHREAD_CANCEL_ASYNCHRONOUS
=
0
,
PTHREAD_CANCEL_DEFERRED
=
1
,
/* Default */
/*
* pthread_mutexattr_{get,set}pshared
* pthread_condattr_{get,set}pshared
*/
PTHREAD_PROCESS_PRIVATE
=
0
,
PTHREAD_PROCESS_SHARED
=
1
,
/*
* pthread_barrier_wait
*/
PTHREAD_BARRIER_SERIAL_THREAD
=
-
1
};
/*
* ====================
* ====================
* Cancelation
* ====================
* ====================
*/
#define PTHREAD_CANCELED ((void *) -1)
/*
* ====================
* ====================
* Once Key
* ====================
* ====================
*/
#define PTHREAD_ONCE_INIT { PTW32_FALSE, 0, 0, 0}
struct
pthread_once_t_
{
int
done
;
/* indicates if user function has been executed */
void
*
lock
;
int
reserved1
;
int
reserved2
;
};
/*
* ====================
* ====================
* Object initialisers
* ====================
* ====================
*/
#define PTHREAD_MUTEX_INITIALIZER ((pthread_mutex_t) -1)
#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER ((pthread_mutex_t) -2)
#define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER ((pthread_mutex_t) -3)
/*
* Compatibility with LinuxThreads
*/
#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP PTHREAD_RECURSIVE_MUTEX_INITIALIZER
#define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP PTHREAD_ERRORCHECK_MUTEX_INITIALIZER
#define PTHREAD_COND_INITIALIZER ((pthread_cond_t) -1)
#define PTHREAD_RWLOCK_INITIALIZER ((pthread_rwlock_t) -1)
#define PTHREAD_SPINLOCK_INITIALIZER ((pthread_spinlock_t) -1)
/*
* Mutex types.
*/
enum
{
/* Compatibility with LinuxThreads */
PTHREAD_MUTEX_FAST_NP
,
PTHREAD_MUTEX_RECURSIVE_NP
,
PTHREAD_MUTEX_ERRORCHECK_NP
,
PTHREAD_MUTEX_TIMED_NP
=
PTHREAD_MUTEX_FAST_NP
,
PTHREAD_MUTEX_ADAPTIVE_NP
=
PTHREAD_MUTEX_FAST_NP
,
/* For compatibility with POSIX */
PTHREAD_MUTEX_NORMAL
=
PTHREAD_MUTEX_FAST_NP
,
PTHREAD_MUTEX_RECURSIVE
=
PTHREAD_MUTEX_RECURSIVE_NP
,
PTHREAD_MUTEX_ERRORCHECK
=
PTHREAD_MUTEX_ERRORCHECK_NP
,
PTHREAD_MUTEX_DEFAULT
=
PTHREAD_MUTEX_NORMAL
};
typedef
struct
ptw32_cleanup_t
ptw32_cleanup_t
;
#if defined(_MSC_VER)
/* Disable MSVC 'anachronism used' warning */
#pragma warning( disable : 4229 )
#endif
typedef
void
(
*
PTW32_CDECL
ptw32_cleanup_callback_t
)(
void
*
);
#if defined(_MSC_VER)
#pragma warning( default : 4229 )
#endif
struct
ptw32_cleanup_t
{
ptw32_cleanup_callback_t
routine
;
void
*
arg
;
struct
ptw32_cleanup_t
*
prev
;
};
#ifdef __CLEANUP_SEH
/*
* WIN32 SEH version of cancel cleanup.
*/
#define pthread_cleanup_push( _rout, _arg ) \
{ \
ptw32_cleanup_t _cleanup; \
\
_cleanup.routine = (ptw32_cleanup_callback_t)(_rout); \
_cleanup.arg = (_arg); \
__try \
{ \
#define pthread_cleanup_pop( _execute ) \
} \
__finally \
{ \
if( _execute || AbnormalTermination()) \
{ \
(*(_cleanup.routine))( _cleanup.arg ); \
} \
} \
}
#else
/* __CLEANUP_SEH */
#ifdef __CLEANUP_C
/*
* C implementation of PThreads cancel cleanup
*/
#define pthread_cleanup_push( _rout, _arg ) \
{ \
ptw32_cleanup_t _cleanup; \
\
ptw32_push_cleanup( &_cleanup, (ptw32_cleanup_callback_t) (_rout), (_arg) ); \
#define pthread_cleanup_pop( _execute ) \
(void) ptw32_pop_cleanup( _execute ); \
}
#else
/* __CLEANUP_C */
#ifdef __CLEANUP_CXX
/*
* C++ version of cancel cleanup.
* - John E. Bossom.
*/
class
PThreadCleanup
{
/*
* PThreadCleanup
*
* Purpose
* This class is a C++ helper class that is
* used to implement pthread_cleanup_push/
* pthread_cleanup_pop.
* The destructor of this class automatically
* pops the pushed cleanup routine regardless
* of how the code exits the scope
* (i.e. such as by an exception)
*/
ptw32_cleanup_callback_t
cleanUpRout
;
void
*
obj
;
int
executeIt
;
public:
PThreadCleanup
()
:
cleanUpRout
(
0
),
obj
(
0
),
executeIt
(
0
)
/*
* No cleanup performed
*/
{
}
PThreadCleanup
(
ptw32_cleanup_callback_t
routine
,
void
*
arg
)
:
cleanUpRout
(
routine
),
obj
(
arg
),
executeIt
(
1
)
/*
* Registers a cleanup routine for 'arg'
*/
{
}
~
PThreadCleanup
()
{
if
(
executeIt
&&
((
void
*
)
cleanUpRout
!=
(
void
*
)
0
)
)
{
(
void
)
(
*
cleanUpRout
)(
obj
);
}
}
void
execute
(
int
exec
)
{
executeIt
=
exec
;
}
};
/*
* C++ implementation of PThreads cancel cleanup;
* This implementation takes advantage of a helper
* class who's destructor automatically calls the
* cleanup routine if we exit our scope weirdly
*/
#define pthread_cleanup_push( _rout, _arg ) \
{ \
PThreadCleanup cleanup((ptw32_cleanup_callback_t)(_rout), \
(void *) (_arg) );
#define pthread_cleanup_pop( _execute ) \
cleanup.execute( _execute ); \
}
#else
#error ERROR [__FILE__, line __LINE__]: Cleanup type undefined.
#endif
/* __CLEANUP_CXX */
#endif
/* __CLEANUP_C */
#endif
/* __CLEANUP_SEH */
/*
* ===============
* ===============
* Methods
* ===============
* ===============
*/
/*
* PThread Attribute Functions
*/
PTW32_DLLPORT
int
PTW32_CDECL
pthread_attr_init
(
pthread_attr_t
*
attr
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_attr_destroy
(
pthread_attr_t
*
attr
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_attr_getdetachstate
(
const
pthread_attr_t
*
attr
,
int
*
detachstate
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_attr_getstackaddr
(
const
pthread_attr_t
*
attr
,
void
**
stackaddr
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_attr_getstacksize
(
const
pthread_attr_t
*
attr
,
size_t
*
stacksize
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_attr_setdetachstate
(
pthread_attr_t
*
attr
,
int
detachstate
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_attr_setstackaddr
(
pthread_attr_t
*
attr
,
void
*
stackaddr
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_attr_setstacksize
(
pthread_attr_t
*
attr
,
size_t
stacksize
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_attr_getschedparam
(
const
pthread_attr_t
*
attr
,
struct
sched_param
*
param
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_attr_setschedparam
(
pthread_attr_t
*
attr
,
const
struct
sched_param
*
param
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_attr_setschedpolicy
(
pthread_attr_t
*
,
int
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_attr_getschedpolicy
(
pthread_attr_t
*
,
int
*
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_attr_setinheritsched
(
pthread_attr_t
*
attr
,
int
inheritsched
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_attr_getinheritsched
(
pthread_attr_t
*
attr
,
int
*
inheritsched
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_attr_setscope
(
pthread_attr_t
*
,
int
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_attr_getscope
(
const
pthread_attr_t
*
,
int
*
);
/*
* PThread Functions
*/
PTW32_DLLPORT
int
PTW32_CDECL
pthread_create
(
pthread_t
*
tid
,
const
pthread_attr_t
*
attr
,
void
*
(
*
start
)
(
void
*
),
void
*
arg
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_detach
(
pthread_t
tid
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_equal
(
pthread_t
t1
,
pthread_t
t2
);
PTW32_DLLPORT
void
PTW32_CDECL
pthread_exit
(
void
*
value_ptr
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_join
(
pthread_t
thread
,
void
**
value_ptr
);
PTW32_DLLPORT
pthread_t
PTW32_CDECL
pthread_self
(
void
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_cancel
(
pthread_t
thread
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_setcancelstate
(
int
state
,
int
*
oldstate
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_setcanceltype
(
int
type
,
int
*
oldtype
);
PTW32_DLLPORT
void
PTW32_CDECL
pthread_testcancel
(
void
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_once
(
pthread_once_t
*
once_control
,
void
(
*
init_routine
)
(
void
));
#if PTW32_LEVEL >= PTW32_LEVEL_MAX
PTW32_DLLPORT
ptw32_cleanup_t
*
PTW32_CDECL
ptw32_pop_cleanup
(
int
execute
);
PTW32_DLLPORT
void
PTW32_CDECL
ptw32_push_cleanup
(
ptw32_cleanup_t
*
cleanup
,
void
(
*
routine
)
(
void
*
),
void
*
arg
);
#endif
/* PTW32_LEVEL >= PTW32_LEVEL_MAX */
/*
* Thread Specific Data Functions
*/
PTW32_DLLPORT
int
PTW32_CDECL
pthread_key_create
(
pthread_key_t
*
key
,
void
(
*
destructor
)
(
void
*
));
PTW32_DLLPORT
int
PTW32_CDECL
pthread_key_delete
(
pthread_key_t
key
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_setspecific
(
pthread_key_t
key
,
const
void
*
value
);
PTW32_DLLPORT
void
*
PTW32_CDECL
pthread_getspecific
(
pthread_key_t
key
);
/*
* Mutex Attribute Functions
*/
PTW32_DLLPORT
int
PTW32_CDECL
pthread_mutexattr_init
(
pthread_mutexattr_t
*
attr
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_mutexattr_destroy
(
pthread_mutexattr_t
*
attr
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_mutexattr_getpshared
(
const
pthread_mutexattr_t
*
attr
,
int
*
pshared
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_mutexattr_setpshared
(
pthread_mutexattr_t
*
attr
,
int
pshared
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_mutexattr_settype
(
pthread_mutexattr_t
*
attr
,
int
kind
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_mutexattr_gettype
(
pthread_mutexattr_t
*
attr
,
int
*
kind
);
/*
* Barrier Attribute Functions
*/
PTW32_DLLPORT
int
PTW32_CDECL
pthread_barrierattr_init
(
pthread_barrierattr_t
*
attr
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_barrierattr_destroy
(
pthread_barrierattr_t
*
attr
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_barrierattr_getpshared
(
const
pthread_barrierattr_t
*
attr
,
int
*
pshared
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_barrierattr_setpshared
(
pthread_barrierattr_t
*
attr
,
int
pshared
);
/*
* Mutex Functions
*/
PTW32_DLLPORT
int
PTW32_CDECL
pthread_mutex_init
(
pthread_mutex_t
*
mutex
,
const
pthread_mutexattr_t
*
attr
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_mutex_destroy
(
pthread_mutex_t
*
mutex
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_mutex_lock
(
pthread_mutex_t
*
mutex
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_mutex_timedlock
(
pthread_mutex_t
*
mutex
,
const
struct
timespec
*
abstime
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_mutex_trylock
(
pthread_mutex_t
*
mutex
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_mutex_unlock
(
pthread_mutex_t
*
mutex
);
/*
* Spinlock Functions
*/
PTW32_DLLPORT
int
PTW32_CDECL
pthread_spin_init
(
pthread_spinlock_t
*
lock
,
int
pshared
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_spin_destroy
(
pthread_spinlock_t
*
lock
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_spin_lock
(
pthread_spinlock_t
*
lock
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_spin_trylock
(
pthread_spinlock_t
*
lock
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_spin_unlock
(
pthread_spinlock_t
*
lock
);
/*
* Barrier Functions
*/
PTW32_DLLPORT
int
PTW32_CDECL
pthread_barrier_init
(
pthread_barrier_t
*
barrier
,
const
pthread_barrierattr_t
*
attr
,
unsigned
int
count
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_barrier_destroy
(
pthread_barrier_t
*
barrier
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_barrier_wait
(
pthread_barrier_t
*
barrier
);
/*
* Condition Variable Attribute Functions
*/
PTW32_DLLPORT
int
PTW32_CDECL
pthread_condattr_init
(
pthread_condattr_t
*
attr
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_condattr_destroy
(
pthread_condattr_t
*
attr
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_condattr_getpshared
(
const
pthread_condattr_t
*
attr
,
int
*
pshared
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_condattr_setpshared
(
pthread_condattr_t
*
attr
,
int
pshared
);
/*
* Condition Variable Functions
*/
PTW32_DLLPORT
int
PTW32_CDECL
pthread_cond_init
(
pthread_cond_t
*
cond
,
const
pthread_condattr_t
*
attr
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_cond_destroy
(
pthread_cond_t
*
cond
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_cond_wait
(
pthread_cond_t
*
cond
,
pthread_mutex_t
*
mutex
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_cond_timedwait
(
pthread_cond_t
*
cond
,
pthread_mutex_t
*
mutex
,
const
struct
timespec
*
abstime
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_cond_signal
(
pthread_cond_t
*
cond
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_cond_broadcast
(
pthread_cond_t
*
cond
);
/*
* Scheduling
*/
PTW32_DLLPORT
int
PTW32_CDECL
pthread_setschedparam
(
pthread_t
thread
,
int
policy
,
const
struct
sched_param
*
param
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_getschedparam
(
pthread_t
thread
,
int
*
policy
,
struct
sched_param
*
param
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_setconcurrency
(
int
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_getconcurrency
(
void
);
/*
* Read-Write Lock Functions
*/
PTW32_DLLPORT
int
PTW32_CDECL
pthread_rwlock_init
(
pthread_rwlock_t
*
lock
,
const
pthread_rwlockattr_t
*
attr
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_rwlock_destroy
(
pthread_rwlock_t
*
lock
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_rwlock_tryrdlock
(
pthread_rwlock_t
*
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_rwlock_trywrlock
(
pthread_rwlock_t
*
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_rwlock_rdlock
(
pthread_rwlock_t
*
lock
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_rwlock_timedrdlock
(
pthread_rwlock_t
*
lock
,
const
struct
timespec
*
abstime
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_rwlock_wrlock
(
pthread_rwlock_t
*
lock
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_rwlock_timedwrlock
(
pthread_rwlock_t
*
lock
,
const
struct
timespec
*
abstime
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_rwlock_unlock
(
pthread_rwlock_t
*
lock
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_rwlockattr_init
(
pthread_rwlockattr_t
*
attr
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_rwlockattr_destroy
(
pthread_rwlockattr_t
*
attr
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_rwlockattr_getpshared
(
const
pthread_rwlockattr_t
*
attr
,
int
*
pshared
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_rwlockattr_setpshared
(
pthread_rwlockattr_t
*
attr
,
int
pshared
);
#if PTW32_LEVEL >= PTW32_LEVEL_MAX - 1
/*
* Signal Functions. Should be defined in <signal.h> but MSVC and MinGW32
* already have signal.h that don't define these.
*/
PTW32_DLLPORT
int
PTW32_CDECL
pthread_kill
(
pthread_t
thread
,
int
sig
);
/*
* Non-portable functions
*/
/*
* Compatibility with Linux.
*/
PTW32_DLLPORT
int
PTW32_CDECL
pthread_mutexattr_setkind_np
(
pthread_mutexattr_t
*
attr
,
int
kind
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_mutexattr_getkind_np
(
pthread_mutexattr_t
*
attr
,
int
*
kind
);
/*
* Possibly supported by other POSIX threads implementations
*/
PTW32_DLLPORT
int
PTW32_CDECL
pthread_delay_np
(
struct
timespec
*
interval
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_num_processors_np
(
void
);
/*
* Useful if an application wants to statically link
* the lib rather than load the DLL at run-time.
*/
PTW32_DLLPORT
int
PTW32_CDECL
pthread_win32_process_attach_np
(
void
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_win32_process_detach_np
(
void
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_win32_thread_attach_np
(
void
);
PTW32_DLLPORT
int
PTW32_CDECL
pthread_win32_thread_detach_np
(
void
);
/*
* Features that are auto-detected at load/run time.
*/
PTW32_DLLPORT
int
PTW32_CDECL
pthread_win32_test_features_np
(
int
);
enum
ptw32_features
{
PTW32_SYSTEM_INTERLOCKED_COMPARE_EXCHANGE
=
0x0001
,
/* System provides it. */
PTW32_ALERTABLE_ASYNC_CANCEL
=
0x0002
/* Can cancel blocked threads. */
};
/*
* Register a system time change with the library.
* Causes the library to perform various functions
* in response to the change. Should be called whenever
* the application's top level window receives a
* WM_TIMECHANGE message. It can be passed directly to
* pthread_create() as a new thread if desired.
*/
PTW32_DLLPORT
void
*
PTW32_CDECL
pthread_timechange_handler_np
(
void
*
);
#endif
/*PTW32_LEVEL >= PTW32_LEVEL_MAX - 1 */
#if PTW32_LEVEL >= PTW32_LEVEL_MAX
/*
* Returns the Win32 HANDLE for the POSIX thread.
*/
PTW32_DLLPORT
HANDLE
PTW32_CDECL
pthread_getw32threadhandle_np
(
pthread_t
thread
);
/*
* Protected Methods
*
* This function blocks until the given WIN32 handle
* is signaled or pthread_cancel had been called.
* This function allows the caller to hook into the
* PThreads cancel mechanism. It is implemented using
*
* WaitForMultipleObjects
*
* on 'waitHandle' and a manually reset WIN32 Event
* used to implement pthread_cancel. The 'timeout'
* argument to TimedWait is simply passed to
* WaitForMultipleObjects.
*/
PTW32_DLLPORT
int
PTW32_CDECL
pthreadCancelableWait
(
HANDLE
waitHandle
);
PTW32_DLLPORT
int
PTW32_CDECL
pthreadCancelableTimedWait
(
HANDLE
waitHandle
,
DWORD
timeout
);
#endif
/* PTW32_LEVEL >= PTW32_LEVEL_MAX */
/*
* Thread-Safe C Runtime Library Mappings.
*/
#ifndef _UWIN
# if defined(NEED_ERRNO)
PTW32_DLLPORT
int
*
PTW32_CDECL
_errno
(
void
);
# else
# ifndef errno
# if (defined(_MT) || defined(_DLL))
__declspec
(
dllimport
)
extern
int
*
__cdecl
_errno
(
void
);
# define errno (*_errno())
# endif
# endif
# endif
#endif
/*
* WIN32 C runtime library had been made thread-safe
* without affecting the user interface. Provide
* mappings from the UNIX thread-safe versions to
* the standard C runtime library calls.
* Only provide function mappings for functions that
* actually exist on WIN32.
*/
#if !defined(__MINGW32__)
#define strtok_r( _s, _sep, _lasts ) \
( *(_lasts) = strtok( (_s), (_sep) ) )
#endif
/* !__MINGW32__ */
#define asctime_r( _tm, _buf ) \
( strcpy( (_buf), asctime( (_tm) ) ), \
(_buf) )
#define ctime_r( _clock, _buf ) \
( strcpy( (_buf), ctime( (_clock) ) ), \
(_buf) )
#define gmtime_r( _clock, _result ) \
( *(_result) = *gmtime( (_clock) ), \
(_result) )
#define localtime_r( _clock, _result ) \
( *(_result) = *localtime( (_clock) ), \
(_result) )
#define rand_r( _seed ) \
( _seed == _seed? rand() : rand() )
/*
* Some compiler environments don't define some things.
*/
#if defined(__BORLANDC__)
# define _ftime ftime
# define _timeb timeb
#endif
#ifdef __cplusplus
/*
* Internal exceptions
*/
class
ptw32_exception
{};
class
ptw32_exception_cancel
:
public
ptw32_exception
{};
class
ptw32_exception_exit
:
public
ptw32_exception
{};
#endif
#if PTW32_LEVEL >= PTW32_LEVEL_MAX
/* FIXME: This is only required if the library was built using SEH */
/*
* Get internal SEH tag
*/
PTW32_DLLPORT
DWORD
PTW32_CDECL
ptw32_get_exception_services_code
(
void
);
#endif
/* PTW32_LEVEL >= PTW32_LEVEL_MAX */
#ifndef PTW32_BUILD
#ifdef __CLEANUP_SEH
/*
* Redefine the SEH __except keyword to ensure that applications
* propagate our internal exceptions up to the library's internal handlers.
*/
#define __except( E ) \
__except( ( GetExceptionCode() == ptw32_get_exception_services_code() ) \
? EXCEPTION_CONTINUE_SEARCH : ( E ) )
#endif
/* __CLEANUP_SEH */
#ifdef __CLEANUP_CXX
/*
* Redefine the C++ catch keyword to ensure that applications
* propagate our internal exceptions up to the library's internal handlers.
*/
#ifdef _MSC_VER
/*
* WARNING: Replace any 'catch( ... )' with 'PtW32CatchAll'
* if you want Pthread-Win32 cancelation and pthread_exit to work.
*/
#ifndef PtW32NoCatchWarn
#pragma message("Specify \"/DPtW32NoCatchWarn\" compiler flag to skip this message.")
#pragma message("------------------------------------------------------------------")
#pragma message("When compiling applications with MSVC++ and C++ exception handling:")
#pragma message(" Replace any 'catch( ... )' in routines called from POSIX threads")
#pragma message(" with 'PtW32CatchAll' or 'CATCHALL' if you want POSIX thread")
#pragma message(" cancelation and pthread_exit to work. For example:")
#pragma message("")
#pragma message(" #ifdef PtW32CatchAll")
#pragma message(" PtW32CatchAll")
#pragma message(" #else")
#pragma message(" catch(...)")
#pragma message(" #endif")
#pragma message(" {")
#pragma message("
/* Catchall block processing */
")
#pragma message(" }")
#pragma message("------------------------------------------------------------------")
#endif
#define PtW32CatchAll \
catch( ptw32_exception & ) { throw; } \
catch( ... )
#else
/* _MSC_VER */
#define catch( E ) \
catch( ptw32_exception & ) { throw; } \
catch( E )
#endif
/* _MSC_VER */
#endif
/* __CLEANUP_CXX */
#endif
/* ! PTW32_BUILD */
#ifdef __cplusplus
}
/* End of extern "C" */
#endif
/* __cplusplus */
#ifdef PTW32__HANDLE_DEF
# undef HANDLE
#endif
#ifdef PTW32__DWORD_DEF
# undef DWORD
#endif
#undef PTW32_LEVEL
#undef PTW32_LEVEL_MAX
#endif
/* ! RC_INVOKED */
#endif
/* PTHREAD_H */
libraries/pthreads/include/sched.h
0 → 100644
View file @
cb75edd4
/*
* Module: sched.h
*
* Purpose:
* Provides an implementation of POSIX realtime extensions
* as defined in
*
* POSIX 1003.1b-1993 (POSIX.1b)
*
* --------------------------------------------------------------------------
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
* Copyright(C) 1999,2005 Pthreads-win32 contributors
*
* Contact Email: rpj@callisto.canberra.edu.au
*
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
* http://sources.redhat.com/pthreads-win32/contributors.html
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library in the file COPYING.LIB;
* if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifndef _SCHED_H
#define _SCHED_H
#undef PTW32_LEVEL
#if defined(_POSIX_SOURCE)
#define PTW32_LEVEL 0
/* Early POSIX */
#endif
#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309
#undef PTW32_LEVEL
#define PTW32_LEVEL 1
/* Include 1b, 1c and 1d */
#endif
#if defined(INCLUDE_NP)
#undef PTW32_LEVEL
#define PTW32_LEVEL 2
/* Include Non-Portable extensions */
#endif
#define PTW32_LEVEL_MAX 3
#if !defined(PTW32_LEVEL)
#define PTW32_LEVEL PTW32_LEVEL_MAX
/* Include everything */
#endif
#if __GNUC__ && ! defined (__declspec)
# error Please upgrade your GNU compiler to one that supports __declspec.
#endif
/*
* When building the DLL code, you should define PTW32_BUILD so that
* the variables/functions are exported correctly. When using the DLL,
* do NOT define PTW32_BUILD, and then the variables/functions will
* be imported correctly.
*/
#ifndef PTW32_STATIC_LIB
# ifdef PTW32_BUILD
# define PTW32_DLLPORT __declspec (dllexport)
# else
# define PTW32_DLLPORT __declspec (dllimport)
# endif
#else
# define PTW32_DLLPORT
#endif
/*
* This is a duplicate of what is in the autoconf config.h,
* which is only used when building the pthread-win32 libraries.
*/
#ifndef PTW32_CONFIG_H
# if defined(WINCE)
# define NEED_ERRNO
# define NEED_SEM
# endif
# if defined(_UWIN) || defined(__MINGW32__)
# define HAVE_MODE_T
# endif
#endif
/*
*
*/
#if PTW32_LEVEL >= PTW32_LEVEL_MAX
#ifdef NEED_ERRNO
#include "need_errno.h"
#else
#include <errno.h>
#endif
#endif
/* PTW32_LEVEL >= PTW32_LEVEL_MAX */
#if defined(__MINGW32__) || defined(_UWIN)
#if PTW32_LEVEL >= PTW32_LEVEL_MAX
/* For pid_t */
# include <sys/types.h>
/* Required by Unix 98 */
# include <time.h>
#endif
/* PTW32_LEVEL >= PTW32_LEVEL_MAX */
#else
typedef
int
pid_t
;
#endif
/* Thread scheduling policies */
enum
{
SCHED_OTHER
=
0
,
SCHED_FIFO
,
SCHED_RR
,
SCHED_MIN
=
SCHED_OTHER
,
SCHED_MAX
=
SCHED_RR
};
struct
sched_param
{
int
sched_priority
;
};
#ifdef __cplusplus
extern
"C"
{
#endif
/* __cplusplus */
PTW32_DLLPORT
int
__cdecl
sched_yield
(
void
);
PTW32_DLLPORT
int
__cdecl
sched_get_priority_min
(
int
policy
);
PTW32_DLLPORT
int
__cdecl
sched_get_priority_max
(
int
policy
);
PTW32_DLLPORT
int
__cdecl
sched_setscheduler
(
pid_t
pid
,
int
policy
);
PTW32_DLLPORT
int
__cdecl
sched_getscheduler
(
pid_t
pid
);
/*
* Note that this macro returns ENOTSUP rather than
* ENOSYS as might be expected. However, returning ENOSYS
* should mean that sched_get_priority_{min,max} are
* not implemented as well as sched_rr_get_interval.
* This is not the case, since we just don't support
* round-robin scheduling. Therefore I have chosen to
* return the same value as sched_setscheduler when
* SCHED_RR is passed to it.
*/
#define sched_rr_get_interval(_pid, _interval) \
( errno = ENOTSUP, (int) -1 )
#ifdef __cplusplus
}
/* End of extern "C" */
#endif
/* __cplusplus */
#undef PTW32_LEVEL
#undef PTW32_LEVEL_MAX
#endif
/* !_SCHED_H */
libraries/pthreads/include/semaphore.h
0 → 100644
View file @
cb75edd4
/*
* Module: semaphore.h
*
* Purpose:
* Semaphores aren't actually part of the PThreads standard.
* They are defined by the POSIX Standard:
*
* POSIX 1003.1b-1993 (POSIX.1b)
*
* --------------------------------------------------------------------------
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
* Copyright(C) 1999,2005 Pthreads-win32 contributors
*
* Contact Email: rpj@callisto.canberra.edu.au
*
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
* http://sources.redhat.com/pthreads-win32/contributors.html
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library in the file COPYING.LIB;
* if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined( SEMAPHORE_H )
#define SEMAPHORE_H
#undef PTW32_LEVEL
#if defined(_POSIX_SOURCE)
#define PTW32_LEVEL 0
/* Early POSIX */
#endif
#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309
#undef PTW32_LEVEL
#define PTW32_LEVEL 1
/* Include 1b, 1c and 1d */
#endif
#if defined(INCLUDE_NP)
#undef PTW32_LEVEL
#define PTW32_LEVEL 2
/* Include Non-Portable extensions */
#endif
#define PTW32_LEVEL_MAX 3
#if !defined(PTW32_LEVEL)
#define PTW32_LEVEL PTW32_LEVEL_MAX
/* Include everything */
#endif
#if __GNUC__ && ! defined (__declspec)
# error Please upgrade your GNU compiler to one that supports __declspec.
#endif
/*
* When building the DLL code, you should define PTW32_BUILD so that
* the variables/functions are exported correctly. When using the DLL,
* do NOT define PTW32_BUILD, and then the variables/functions will
* be imported correctly.
*/
#ifndef PTW32_STATIC_LIB
# ifdef PTW32_BUILD
# define PTW32_DLLPORT __declspec (dllexport)
# else
# define PTW32_DLLPORT __declspec (dllimport)
# endif
#else
# define PTW32_DLLPORT
#endif
/*
* This is a duplicate of what is in the autoconf config.h,
* which is only used when building the pthread-win32 libraries.
*/
#ifndef PTW32_CONFIG_H
# if defined(WINCE)
# define NEED_ERRNO
# define NEED_SEM
# endif
# if defined(_UWIN) || defined(__MINGW32__)
# define HAVE_MODE_T
# endif
#endif
/*
*
*/
#if PTW32_LEVEL >= PTW32_LEVEL_MAX
#ifdef NEED_ERRNO
#include "need_errno.h"
#else
#include <errno.h>
#endif
#endif
/* PTW32_LEVEL >= PTW32_LEVEL_MAX */
#define _POSIX_SEMAPHORES
#ifdef __cplusplus
extern
"C"
{
#endif
/* __cplusplus */
#ifndef HAVE_MODE_T
typedef
unsigned
int
mode_t
;
#endif
typedef
struct
sem_t_
*
sem_t
;
PTW32_DLLPORT
int
__cdecl
sem_init
(
sem_t
*
sem
,
int
pshared
,
unsigned
int
value
);
PTW32_DLLPORT
int
__cdecl
sem_destroy
(
sem_t
*
sem
);
PTW32_DLLPORT
int
__cdecl
sem_trywait
(
sem_t
*
sem
);
PTW32_DLLPORT
int
__cdecl
sem_wait
(
sem_t
*
sem
);
PTW32_DLLPORT
int
__cdecl
sem_timedwait
(
sem_t
*
sem
,
const
struct
timespec
*
abstime
);
PTW32_DLLPORT
int
__cdecl
sem_post
(
sem_t
*
sem
);
PTW32_DLLPORT
int
__cdecl
sem_post_multiple
(
sem_t
*
sem
,
int
count
);
PTW32_DLLPORT
int
__cdecl
sem_open
(
const
char
*
name
,
int
oflag
,
mode_t
mode
,
unsigned
int
value
);
PTW32_DLLPORT
int
__cdecl
sem_close
(
sem_t
*
sem
);
PTW32_DLLPORT
int
__cdecl
sem_unlink
(
const
char
*
name
);
PTW32_DLLPORT
int
__cdecl
sem_getvalue
(
sem_t
*
sem
,
int
*
sval
);
#ifdef __cplusplus
}
/* End of extern "C" */
#endif
/* __cplusplus */
#undef PTW32_LEVEL
#undef PTW32_LEVEL_MAX
#endif
/* !SEMAPHORE_H */
libraries/pthreads/lib/pthreadVC2.dll
0 → 100644
View file @
cb75edd4
File added
libraries/pthreads/lib/pthreadVC2.lib
0 → 100644
View file @
cb75edd4
File added
platforms/opencl/sharedTarget/CMakeLists.txt
View file @
cb75edd4
#
#
# Include OpenCL related files.
# Include OpenCL related files.
#
#
# INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/../FindOpenCL.cmake)
# INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/../FindOpenCL.cmake)
INCLUDE_DIRECTORIES
(
${
OPENCL_INCLUDE_DIR
}
)
INCLUDE_DIRECTORIES
(
${
OPENCL_INCLUDE_DIR
}
)
FILE
(
GLOB OPENCL_KERNELS
${
CL_SOURCE_DIR
}
/kernels/*.cl
)
FILE
(
GLOB OPENCL_KERNELS
${
CL_SOURCE_DIR
}
/kernels/*.cl
)
ADD_CUSTOM_COMMAND
(
OUTPUT
${
CL_KERNELS_CPP
}
${
CL_KERNELS_H
}
ADD_CUSTOM_COMMAND
(
OUTPUT
${
CL_KERNELS_CPP
}
${
CL_KERNELS_H
}
COMMAND
${
CMAKE_COMMAND
}
COMMAND
${
CMAKE_COMMAND
}
ARGS -D CL_SOURCE_DIR=
${
CL_SOURCE_DIR
}
-D CL_KERNELS_CPP=
${
CL_KERNELS_CPP
}
-D CL_KERNELS_H=
${
CL_KERNELS_H
}
-P
${
CMAKE_CURRENT_SOURCE_DIR
}
/../EncodeCLFiles.cmake
ARGS -D CL_SOURCE_DIR=
${
CL_SOURCE_DIR
}
-D CL_KERNELS_CPP=
${
CL_KERNELS_CPP
}
-D CL_KERNELS_H=
${
CL_KERNELS_H
}
-P
${
CMAKE_CURRENT_SOURCE_DIR
}
/../EncodeCLFiles.cmake
DEPENDS
${
OPENCL_KERNELS
}
DEPENDS
${
OPENCL_KERNELS
}
)
)
SET_SOURCE_FILES_PROPERTIES
(
${
CL_KERNELS_CPP
}
${
CL_KERNELS_H
}
PROPERTIES GENERATED TRUE
)
SET_SOURCE_FILES_PROPERTIES
(
${
CL_KERNELS_CPP
}
${
CL_KERNELS_H
}
PROPERTIES GENERATED TRUE
)
ADD_LIBRARY
(
${
SHARED_TARGET
}
SHARED
${
SOURCE_FILES
}
${
SOURCE_INCLUDE_FILES
}
${
API_ABS_INCLUDE_FILES
}
)
ADD_LIBRARY
(
${
SHARED_TARGET
}
SHARED
${
SOURCE_FILES
}
${
SOURCE_INCLUDE_FILES
}
${
API_ABS_INCLUDE_FILES
}
)
IF
(
UNIX AND CMAKE_BUILD_TYPE MATCHES Debug
)
IF
(
UNIX AND CMAKE_BUILD_TYPE MATCHES Debug
)
SET
(
MAIN_OPENMM_LIB
${
OPENMM_LIBRARY_NAME
}
_d
)
SET
(
MAIN_OPENMM_LIB
${
OPENMM_LIBRARY_NAME
}
_d
)
ELSE
(
UNIX AND CMAKE_BUILD_TYPE MATCHES Debug
)
ELSE
(
UNIX AND CMAKE_BUILD_TYPE MATCHES Debug
)
SET
(
MAIN_OPENMM_LIB
${
OPENMM_LIBRARY_NAME
}
)
SET
(
MAIN_OPENMM_LIB
${
OPENMM_LIBRARY_NAME
}
)
ENDIF
(
UNIX AND CMAKE_BUILD_TYPE MATCHES Debug
)
ENDIF
(
UNIX AND CMAKE_BUILD_TYPE MATCHES Debug
)
TARGET_LINK_LIBRARIES
(
${
SHARED_TARGET
}
${
MAIN_OPENMM_LIB
}
${
OPENCL_LIBRARIES
}
)
TARGET_LINK_LIBRARIES
(
${
SHARED_TARGET
}
${
MAIN_OPENMM_LIB
}
${
OPENCL_LIBRARIES
}
${
PTHREADS_LIB
}
)
SET_TARGET_PROPERTIES
(
${
SHARED_TARGET
}
PROPERTIES COMPILE_FLAGS
"-DOPENMM_BUILDING_SHARED_LIBRARY"
)
SET_TARGET_PROPERTIES
(
${
SHARED_TARGET
}
PROPERTIES COMPILE_FLAGS
"-DOPENMM_BUILDING_SHARED_LIBRARY"
)
INSTALL_TARGETS
(
/lib/plugins RUNTIME_DIRECTORY /lib/plugins
${
SHARED_TARGET
}
)
INSTALL_TARGETS
(
/lib/plugins RUNTIME_DIRECTORY /lib/plugins
${
SHARED_TARGET
}
)
platforms/opencl/src/OpenCLContext.cpp
View file @
cb75edd4
...
@@ -126,10 +126,10 @@ OpenCLContext::OpenCLContext(int numParticles, int deviceIndex, OpenCLPlatform::
...
@@ -126,10 +126,10 @@ OpenCLContext::OpenCLContext(int numParticles, int deviceIndex, OpenCLPlatform::
cl
::
Kernel
accuracyKernel
(
utilities
,
"determineNativeAccuracy"
);
cl
::
Kernel
accuracyKernel
(
utilities
,
"determineNativeAccuracy"
);
OpenCLArray
<
mm_float8
>
values
(
*
this
,
20
,
"values"
,
true
);
OpenCLArray
<
mm_float8
>
values
(
*
this
,
20
,
"values"
,
true
);
float
nextValue
=
1e-4
;
float
nextValue
=
1e-4
f
;
for
(
int
i
=
0
;
i
<
values
.
getSize
();
++
i
)
{
for
(
int
i
=
0
;
i
<
values
.
getSize
();
++
i
)
{
values
[
i
].
s0
=
nextValue
;
values
[
i
].
s0
=
nextValue
;
nextValue
*=
M_PI
;
nextValue
*=
(
float
)
M_PI
;
}
}
values
.
upload
();
values
.
upload
();
accuracyKernel
.
setArg
<
cl
::
Buffer
>
(
0
,
values
.
getDeviceBuffer
());
accuracyKernel
.
setArg
<
cl
::
Buffer
>
(
0
,
values
.
getDeviceBuffer
());
...
...
platforms/opencl/src/OpenCLIntegrationUtilities.cpp
View file @
cb75edd4
...
@@ -466,7 +466,7 @@ OpenCLIntegrationUtilities::OpenCLIntegrationUtilities(OpenCLContext& context, c
...
@@ -466,7 +466,7 @@ OpenCLIntegrationUtilities::OpenCLIntegrationUtilities(OpenCLContext& context, c
int
c
=
ccmaConstraints
[
index
];
int
c
=
ccmaConstraints
[
index
];
atomsVec
[
i
].
x
=
atom1
[
c
];
atomsVec
[
i
].
x
=
atom1
[
c
];
atomsVec
[
i
].
y
=
atom2
[
c
];
atomsVec
[
i
].
y
=
atom2
[
c
];
distanceVec
[
i
].
w
=
distance
[
c
];
distanceVec
[
i
].
w
=
(
float
)
distance
[
c
];
reducedMassVec
[
i
]
=
(
float
)
(
0.5
/
(
1.0
/
system
.
getParticleMass
(
atom1
[
c
])
+
1.0
/
system
.
getParticleMass
(
atom2
[
c
])));
reducedMassVec
[
i
]
=
(
float
)
(
0.5
/
(
1.0
/
system
.
getParticleMass
(
atom1
[
c
])
+
1.0
/
system
.
getParticleMass
(
atom2
[
c
])));
for
(
unsigned
int
j
=
0
;
j
<
matrix
[
index
].
size
();
j
++
)
{
for
(
unsigned
int
j
=
0
;
j
<
matrix
[
index
].
size
();
j
++
)
{
constraintMatrixColumnVec
[
i
+
j
*
numCCMA
]
=
matrix
[
index
][
j
].
first
;
constraintMatrixColumnVec
[
i
+
j
*
numCCMA
]
=
matrix
[
index
][
j
].
first
;
...
...
platforms/opencl/src/OpenCLKernels.cpp
View file @
cb75edd4
...
@@ -888,10 +888,10 @@ void OpenCLCalcCMAPTorsionForceKernel::initialize(const System& system, const CM
...
@@ -888,10 +888,10 @@ void OpenCLCalcCMAPTorsionForceKernel::initialize(const System& system, const CM
mapPositionsVec
[
i
]
=
mm_int2
(
currentPosition
,
size
);
mapPositionsVec
[
i
]
=
mm_int2
(
currentPosition
,
size
);
currentPosition
+=
4
*
size
*
size
;
currentPosition
+=
4
*
size
*
size
;
for
(
int
j
=
0
;
j
<
size
*
size
;
j
++
)
{
for
(
int
j
=
0
;
j
<
size
*
size
;
j
++
)
{
coeffVec
.
push_back
(
mm_float4
(
c
[
j
][
0
],
c
[
j
][
1
],
c
[
j
][
2
],
c
[
j
][
3
]));
coeffVec
.
push_back
(
mm_float4
(
(
float
)
c
[
j
][
0
],
(
float
)
c
[
j
][
1
],
(
float
)
c
[
j
][
2
],
(
float
)
c
[
j
][
3
]));
coeffVec
.
push_back
(
mm_float4
(
c
[
j
][
4
],
c
[
j
][
5
],
c
[
j
][
6
],
c
[
j
][
7
]));
coeffVec
.
push_back
(
mm_float4
(
(
float
)
c
[
j
][
4
],
(
float
)
c
[
j
][
5
],
(
float
)
c
[
j
][
6
],
(
float
)
c
[
j
][
7
]));
coeffVec
.
push_back
(
mm_float4
(
c
[
j
][
8
],
c
[
j
][
9
],
c
[
j
][
10
],
c
[
j
][
11
]));
coeffVec
.
push_back
(
mm_float4
(
(
float
)
c
[
j
][
8
],
(
float
)
c
[
j
][
9
],
(
float
)
c
[
j
][
10
],
(
float
)
c
[
j
][
11
]));
coeffVec
.
push_back
(
mm_float4
(
c
[
j
][
12
],
c
[
j
][
13
],
c
[
j
][
14
],
c
[
j
][
15
]));
coeffVec
.
push_back
(
mm_float4
(
(
float
)
c
[
j
][
12
],
(
float
)
c
[
j
][
13
],
(
float
)
c
[
j
][
14
],
(
float
)
c
[
j
][
15
]));
}
}
}
}
vector
<
int
>
forceBufferCounter
(
system
.
getNumParticles
(),
0
);
vector
<
int
>
forceBufferCounter
(
system
.
getNumParticles
(),
0
);
...
@@ -1452,7 +1452,7 @@ double OpenCLCalcNonbondedForceKernel::execute(ContextImpl& context, bool includ
...
@@ -1452,7 +1452,7 @@ double OpenCLCalcNonbondedForceKernel::execute(ContextImpl& context, bool includ
if
(
cosSinSums
!=
NULL
&&
cl
.
getContextIndex
()
==
0
)
{
if
(
cosSinSums
!=
NULL
&&
cl
.
getContextIndex
()
==
0
)
{
mm_float4
boxSize
=
cl
.
getPeriodicBoxSize
();
mm_float4
boxSize
=
cl
.
getPeriodicBoxSize
();
mm_float4
recipBoxSize
=
mm_float4
((
float
)
(
2
*
M_PI
/
boxSize
.
x
),
(
float
)
(
2
*
M_PI
/
boxSize
.
y
),
(
float
)
(
2
*
M_PI
/
boxSize
.
z
),
0
);
mm_float4
recipBoxSize
=
mm_float4
((
float
)
(
2
*
M_PI
/
boxSize
.
x
),
(
float
)
(
2
*
M_PI
/
boxSize
.
y
),
(
float
)
(
2
*
M_PI
/
boxSize
.
z
),
0
);
float
recipCoefficient
=
ONE_4PI_EPS0
*
4
*
M_PI
/
(
boxSize
.
x
*
boxSize
.
y
*
boxSize
.
z
);
float
recipCoefficient
=
(
float
)
(
ONE_4PI_EPS0
*
4
*
M_PI
/
(
boxSize
.
x
*
boxSize
.
y
*
boxSize
.
z
)
)
;
ewaldSumsKernel
.
setArg
<
mm_float4
>
(
3
,
recipBoxSize
);
ewaldSumsKernel
.
setArg
<
mm_float4
>
(
3
,
recipBoxSize
);
ewaldSumsKernel
.
setArg
<
cl_float
>
(
4
,
recipCoefficient
);
ewaldSumsKernel
.
setArg
<
cl_float
>
(
4
,
recipCoefficient
);
cl
.
executeKernel
(
ewaldSumsKernel
,
cosSinSums
->
getSize
());
cl
.
executeKernel
(
ewaldSumsKernel
,
cosSinSums
->
getSize
());
...
@@ -1581,7 +1581,7 @@ void OpenCLCalcCustomNonbondedForceKernel::initialize(const System& system, cons
...
@@ -1581,7 +1581,7 @@ void OpenCLCalcCustomNonbondedForceKernel::initialize(const System& system, cons
string
arrayName
=
prefix
+
"table"
+
intToString
(
i
);
string
arrayName
=
prefix
+
"table"
+
intToString
(
i
);
functionDefinitions
.
push_back
(
make_pair
(
name
,
arrayName
));
functionDefinitions
.
push_back
(
make_pair
(
name
,
arrayName
));
functions
[
name
]
=
&
fp
;
functions
[
name
]
=
&
fp
;
tabulatedFunctionParamsVec
[
i
]
=
mm_float4
((
float
)
min
,
(
float
)
max
,
(
float
)
((
values
.
size
()
-
1
)
/
(
max
-
min
)),
values
.
size
()
-
2
);
tabulatedFunctionParamsVec
[
i
]
=
mm_float4
((
float
)
min
,
(
float
)
max
,
(
float
)
((
values
.
size
()
-
1
)
/
(
max
-
min
)),
(
float
)
values
.
size
()
-
2
);
vector
<
mm_float4
>
f
=
OpenCLExpressionUtilities
::
computeFunctionCoefficients
(
values
,
min
,
max
);
vector
<
mm_float4
>
f
=
OpenCLExpressionUtilities
::
computeFunctionCoefficients
(
values
,
min
,
max
);
tabulatedFunctions
.
push_back
(
new
OpenCLArray
<
mm_float4
>
(
cl
,
values
.
size
()
-
1
,
"TabulatedFunction"
));
tabulatedFunctions
.
push_back
(
new
OpenCLArray
<
mm_float4
>
(
cl
,
values
.
size
()
-
1
,
"TabulatedFunction"
));
tabulatedFunctions
[
tabulatedFunctions
.
size
()
-
1
]
->
upload
(
f
);
tabulatedFunctions
[
tabulatedFunctions
.
size
()
-
1
]
->
upload
(
f
);
...
@@ -1932,7 +1932,7 @@ void OpenCLCalcCustomGBForceKernel::initialize(const System& system, const Custo
...
@@ -1932,7 +1932,7 @@ void OpenCLCalcCustomGBForceKernel::initialize(const System& system, const Custo
string
arrayName
=
prefix
+
"table"
+
intToString
(
i
);
string
arrayName
=
prefix
+
"table"
+
intToString
(
i
);
functionDefinitions
.
push_back
(
make_pair
(
name
,
arrayName
));
functionDefinitions
.
push_back
(
make_pair
(
name
,
arrayName
));
functions
[
name
]
=
&
fp
;
functions
[
name
]
=
&
fp
;
tabulatedFunctionParamsVec
[
i
]
=
mm_float4
((
float
)
min
,
(
float
)
max
,
(
float
)
((
values
.
size
()
-
1
)
/
(
max
-
min
)),
values
.
size
()
-
2
);
tabulatedFunctionParamsVec
[
i
]
=
mm_float4
((
float
)
min
,
(
float
)
max
,
(
float
)
((
values
.
size
()
-
1
)
/
(
max
-
min
)),
(
float
)
values
.
size
()
-
2
);
vector
<
mm_float4
>
f
=
OpenCLExpressionUtilities
::
computeFunctionCoefficients
(
values
,
min
,
max
);
vector
<
mm_float4
>
f
=
OpenCLExpressionUtilities
::
computeFunctionCoefficients
(
values
,
min
,
max
);
tabulatedFunctions
.
push_back
(
new
OpenCLArray
<
mm_float4
>
(
cl
,
values
.
size
()
-
1
,
"TabulatedFunction"
));
tabulatedFunctions
.
push_back
(
new
OpenCLArray
<
mm_float4
>
(
cl
,
values
.
size
()
-
1
,
"TabulatedFunction"
));
tabulatedFunctions
[
tabulatedFunctions
.
size
()
-
1
]
->
upload
(
f
);
tabulatedFunctions
[
tabulatedFunctions
.
size
()
-
1
]
->
upload
(
f
);
...
@@ -3003,7 +3003,7 @@ void OpenCLCalcCustomHbondForceKernel::initialize(const System& system, const Cu
...
@@ -3003,7 +3003,7 @@ void OpenCLCalcCustomHbondForceKernel::initialize(const System& system, const Cu
string
arrayName
=
"table"
+
intToString
(
i
);
string
arrayName
=
"table"
+
intToString
(
i
);
functionDefinitions
.
push_back
(
make_pair
(
name
,
arrayName
));
functionDefinitions
.
push_back
(
make_pair
(
name
,
arrayName
));
functions
[
name
]
=
&
fp
;
functions
[
name
]
=
&
fp
;
tabulatedFunctionParamsVec
[
i
]
=
mm_float4
((
float
)
min
,
(
float
)
max
,
(
float
)
((
values
.
size
()
-
1
)
/
(
max
-
min
)),
values
.
size
()
-
2
);
tabulatedFunctionParamsVec
[
i
]
=
mm_float4
((
float
)
min
,
(
float
)
max
,
(
float
)
((
values
.
size
()
-
1
)
/
(
max
-
min
)),
(
float
)
values
.
size
()
-
2
);
vector
<
mm_float4
>
f
=
OpenCLExpressionUtilities
::
computeFunctionCoefficients
(
values
,
min
,
max
);
vector
<
mm_float4
>
f
=
OpenCLExpressionUtilities
::
computeFunctionCoefficients
(
values
,
min
,
max
);
tabulatedFunctions
.
push_back
(
new
OpenCLArray
<
mm_float4
>
(
cl
,
values
.
size
()
-
1
,
"TabulatedFunction"
));
tabulatedFunctions
.
push_back
(
new
OpenCLArray
<
mm_float4
>
(
cl
,
values
.
size
()
-
1
,
"TabulatedFunction"
));
tabulatedFunctions
[
tabulatedFunctions
.
size
()
-
1
]
->
upload
(
f
);
tabulatedFunctions
[
tabulatedFunctions
.
size
()
-
1
]
->
upload
(
f
);
...
@@ -3387,7 +3387,7 @@ void OpenCLIntegrateLangevinStepKernel::execute(ContextImpl& context, const Lang
...
@@ -3387,7 +3387,7 @@ void OpenCLIntegrateLangevinStepKernel::execute(ContextImpl& context, const Lang
p
[
1
]
=
(
cl_float
)
fscale
;
p
[
1
]
=
(
cl_float
)
fscale
;
p
[
2
]
=
(
cl_float
)
noisescale
;
p
[
2
]
=
(
cl_float
)
noisescale
;
params
->
upload
(
p
);
params
->
upload
(
p
);
integration
.
getStepSize
()[
0
].
y
=
stepSize
;
integration
.
getStepSize
()[
0
].
y
=
(
cl_float
)
stepSize
;
integration
.
getStepSize
().
upload
();
integration
.
getStepSize
().
upload
();
prevTemp
=
temperature
;
prevTemp
=
temperature
;
prevFriction
=
friction
;
prevFriction
=
friction
;
...
...
platforms/opencl/src/OpenCLNonbondedUtilities.cpp
View file @
cb75edd4
...
@@ -313,7 +313,7 @@ void OpenCLNonbondedUtilities::updateNeighborListSize() {
...
@@ -313,7 +313,7 @@ void OpenCLNonbondedUtilities::updateNeighborListSize() {
if
(
!
useCutoff
)
if
(
!
useCutoff
)
return
;
return
;
interactionCount
->
download
();
interactionCount
->
download
();
if
(
interactionCount
->
get
(
0
)
<=
interactingTiles
->
getSize
())
if
(
interactionCount
->
get
(
0
)
<=
(
unsigned
int
)
interactingTiles
->
getSize
())
return
;
return
;
// The most recent timestep had too many interactions to fit in the arrays. Make the arrays bigger to prevent
// The most recent timestep had too many interactions to fit in the arrays. Make the arrays bigger to prevent
...
...
platforms/opencl/src/OpenCLParallelKernels.cpp
View file @
cb75edd4
...
@@ -34,17 +34,17 @@ using namespace std;
...
@@ -34,17 +34,17 @@ using namespace std;
*/
*/
#ifdef _MSC_VER
#ifdef _MSC_VER
#include <Windows.h>
#include <Windows.h>
static
long
getTime
()
{
static
long
long
getTime
()
{
FILETIME
ft
;
FILETIME
ft
;
GetSystemTimeAsFileTime
(
&
ft
);
// 100-nanoseconds since 1-1-1601
GetSystemTimeAsFileTime
(
&
ft
);
// 100-nanoseconds since 1-1-1601
ULARGE_INTEGER
result
;
ULARGE_INTEGER
result
;
result
.
LowPart
=
ft
.
dwLowDateTime
;
result
.
LowPart
=
ft
.
dwLowDateTime
;
result
.
HighPart
=
ft
.
dwHighDateTime
;
result
.
HighPart
=
ft
.
dwHighDateTime
;
return
result
/
10
;
return
result
.
QuadPart
/
10
;
}
}
#else
#else
#include <sys/time.h>
#include <sys/time.h>
static
long
getTime
()
{
static
long
long
getTime
()
{
struct
timeval
tod
;
struct
timeval
tod
;
gettimeofday
(
&
tod
,
0
);
gettimeofday
(
&
tod
,
0
);
return
1000000
*
tod
.
tv_sec
+
tod
.
tv_usec
;
return
1000000
*
tod
.
tv_sec
+
tod
.
tv_usec
;
...
@@ -74,7 +74,7 @@ private:
...
@@ -74,7 +74,7 @@ private:
class
OpenCLParallelCalcForcesAndEnergyKernel
::
FinishComputationTask
:
public
OpenCLContext
::
WorkTask
{
class
OpenCLParallelCalcForcesAndEnergyKernel
::
FinishComputationTask
:
public
OpenCLContext
::
WorkTask
{
public:
public:
FinishComputationTask
(
ContextImpl
&
context
,
OpenCLContext
&
cl
,
OpenCLCalcForcesAndEnergyKernel
&
kernel
,
FinishComputationTask
(
ContextImpl
&
context
,
OpenCLContext
&
cl
,
OpenCLCalcForcesAndEnergyKernel
&
kernel
,
bool
includeForce
,
bool
includeEnergy
,
double
&
energy
,
long
&
completionTime
)
:
context
(
context
),
cl
(
cl
),
kernel
(
kernel
),
bool
includeForce
,
bool
includeEnergy
,
double
&
energy
,
long
long
&
completionTime
)
:
context
(
context
),
cl
(
cl
),
kernel
(
kernel
),
includeForce
(
includeForce
),
includeEnergy
(
includeEnergy
),
energy
(
energy
),
completionTime
(
completionTime
)
{
includeForce
(
includeForce
),
includeEnergy
(
includeEnergy
),
energy
(
energy
),
completionTime
(
completionTime
)
{
}
}
void
execute
()
{
void
execute
()
{
...
@@ -91,7 +91,7 @@ private:
...
@@ -91,7 +91,7 @@ private:
OpenCLCalcForcesAndEnergyKernel
&
kernel
;
OpenCLCalcForcesAndEnergyKernel
&
kernel
;
bool
includeForce
,
includeEnergy
;
bool
includeForce
,
includeEnergy
;
double
&
energy
;
double
&
energy
;
long
&
completionTime
;
long
long
&
completionTime
;
};
};
OpenCLParallelCalcForcesAndEnergyKernel
::
OpenCLParallelCalcForcesAndEnergyKernel
(
string
name
,
const
Platform
&
platform
,
OpenCLPlatform
::
PlatformData
&
data
)
:
OpenCLParallelCalcForcesAndEnergyKernel
::
OpenCLParallelCalcForcesAndEnergyKernel
(
string
name
,
const
Platform
&
platform
,
OpenCLPlatform
::
PlatformData
&
data
)
:
...
...
platforms/opencl/src/OpenCLParallelKernels.h
View file @
cb75edd4
...
@@ -76,7 +76,7 @@ private:
...
@@ -76,7 +76,7 @@ private:
class
FinishComputationTask
;
class
FinishComputationTask
;
OpenCLPlatform
::
PlatformData
&
data
;
OpenCLPlatform
::
PlatformData
&
data
;
std
::
vector
<
Kernel
>
kernels
;
std
::
vector
<
Kernel
>
kernels
;
std
::
vector
<
long
>
completionTimes
;
std
::
vector
<
long
long
>
completionTimes
;
std
::
vector
<
int
>
contextTiles
;
std
::
vector
<
int
>
contextTiles
;
};
};
...
...
platforms/opencl/src/OpenCLSort.h
View file @
cb75edd4
...
@@ -87,7 +87,7 @@ public:
...
@@ -87,7 +87,7 @@ public:
sortKernelSize
=
rangeKernelSize
/
2
;
sortKernelSize
=
rangeKernelSize
/
2
;
if
(
rangeKernelSize
>
length
)
if
(
rangeKernelSize
>
length
)
rangeKernelSize
=
length
;
rangeKernelSize
=
length
;
int
maxLocalBuffer
=
(
context
.
getDevice
().
getInfo
<
CL_DEVICE_LOCAL_MEM_SIZE
>
()
/
sizeof
(
TYPE
))
/
2
;
int
maxLocalBuffer
=
(
int
)
(
(
context
.
getDevice
().
getInfo
<
CL_DEVICE_LOCAL_MEM_SIZE
>
()
/
sizeof
(
TYPE
))
/
2
)
;
if
(
sortKernelSize
>
maxLocalBuffer
)
if
(
sortKernelSize
>
maxLocalBuffer
)
sortKernelSize
=
maxLocalBuffer
;
sortKernelSize
=
maxLocalBuffer
;
int
targetBucketSize
=
sortKernelSize
/
2
;
int
targetBucketSize
=
sortKernelSize
/
2
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment