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
10fc2f21
"vscode:/vscode.git/clone" did not exist on "ef70b83e3b35a84aadc5385b02c95c5d1bcf299c"
Commit
10fc2f21
authored
Sep 26, 2008
by
Mark Friedrichs
Browse files
Update
parent
cb130f92
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
357 additions
and
186 deletions
+357
-186
platforms/brook/include/BrookKernelFactory.h
platforms/brook/include/BrookKernelFactory.h
+1
-1
platforms/brook/include/BrookPlatform.h
platforms/brook/include/BrookPlatform.h
+159
-13
platforms/brook/include/BrookStreamFactory.h
platforms/brook/include/BrookStreamFactory.h
+135
-2
platforms/brook/tests/CMakeLists.txt
platforms/brook/tests/CMakeLists.txt
+62
-170
No files found.
platforms/brook/include/BrookKernelFactory.h
View file @
10fc2f21
...
...
@@ -42,7 +42,7 @@ namespace OpenMM {
class
BrookKernelFactory
:
public
KernelFactory
{
public:
KernelImpl
*
createKernelImpl
(
std
::
string
name
,
const
Platform
&
platform
,
OpenMMContextImpl
&
context
)
const
;
KernelImpl
*
createKernelImpl
(
std
::
string
name
,
const
Platform
&
platform
,
OpenMMContextImpl
&
context
)
const
;
};
}
// namespace OpenMM
...
...
platforms/brook/include/BrookPlatform.h
View file @
10fc2f21
...
...
@@ -32,28 +32,174 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
// default float size for Brook
#define BrookOpenMMFloat float
#include "Platform.h"
#include "BrookStreamFactory.h"
namespace
OpenMM
{
/**
* This Platform subclass uses the
reference
implementations of all the OpenMM kernels.
* This Platform subclass uses the
Brook
implementations of all the OpenMM kernels.
*/
class
BrookPlatform
:
public
Platform
{
public:
BrookPlatform
();
std
::
string
getName
()
const
{
return
"Brook"
;
}
double
getSpeed
()
const
{
return
10.0
;
}
bool
supportsDoublePrecision
()
const
;
const
StreamFactory
&
getDefaultStreamFactory
()
const
;
private:
BrookStreamFactory
defaultStreamFactory
;
public:
// return values
static
const
int
DefaultReturnValue
=
0
;
static
const
int
DefaultErrorValue
=
-
1
;
/**
* BrookPlatform constructor
*
*/
BrookPlatform
();
/**
* BrookPlatform constructor
*
* @param defaultAtomStreamWidth stream width
* @param runtime Brook runtime (cal/cpu)
* @param log log file reference
*
*/
BrookPlatform
(
int
atomStreamWdith
,
const
std
::
string
&
runtime
,
FILE
*
log
=
NULL
);
/**
* BrookPlatform destructor
*
*/
~
BrookPlatform
();
/**
* Return platform name
*
* @return "Brook"
*/
std
::
string
getName
()
const
;
/**
* Return platform speed
*
* @return speed
*/
double
getSpeed
(
void
)
const
;
/**
* Return true if BrookPlatform supports double precison
*
* @return true if BrookPlatform supports double precison
*/
bool
supportsDoublePrecision
(
void
)
const
;
const
StreamFactory
&
getDefaultStreamFactory
(
void
)
const
;
/**
* Get the runtime
*
* @return runtime
*/
std
::
string
getRuntime
(
void
);
/**
* Get stream height and size given minimum number of elements in stream
*
* @param size input size of stream
* @param width width of stream
* @param height output height of stream (may be NULL)
*
* @return stream size (=streamWidth*height)
*/
static
int
getStreamSize
(
int
size
,
int
streamWidth
,
int
*
outputHeight
);
/**
* Get default stream width
*
* @return default stream width
*/
int
getAtomStreamWidth
(
void
)
const
;
/**
* Set log file reference
*
* @param log file reference
*
* @return DefaultReturnValue
*
*/
int
setLog
(
FILE
*
log
);
/*
* Get contents of object
*
* @param level of dump
*
* @return string containing contents
*
* */
std
::
string
getContents
(
int
level
)
const
;
/**
* Get log file reference
*
* @return log file reference
*
*/
FILE
*
getLog
(
void
)
const
;
private:
// log file reference
FILE
*
_log
;
BrookStreamFactory
_defaultStreamFactory
;
// default stream width
static
const
int
DefaultAtomStreamWidth
=
32
;
// atom streamwidth
int
_atomStreamWidth
;
// Brook runtime
std
::
string
_runtime
;
/**
* Initialize kernel factory
*
*/
void
_initializeKernelFactory
(
void
);
/**
* Set & validate runtime
*
* @param runtime Brook runtime (cal/cpu)
*
* @throws exception if runtime is invalid
*/
void
_setBrookRuntime
(
const
std
::
string
&
runtime
);
};
}
// namespace OpenMM
...
...
platforms/brook/include/BrookStreamFactory.h
View file @
10fc2f21
...
...
@@ -33,6 +33,7 @@
* -------------------------------------------------------------------------- */
#include "StreamFactory.h"
#include "Platform.h"
namespace
OpenMM
{
...
...
@@ -41,8 +42,140 @@ namespace OpenMM {
*/
class
BrookStreamFactory
:
public
StreamFactory
{
public:
StreamImpl
*
createStreamImpl
(
std
::
string
name
,
int
size
,
Stream
::
DataType
type
,
int
streamWidth
,
const
Platform
&
platform
,
OpenMMContextImpl
&
context
)
const
;
public:
BrookStreamFactory
(
);
~
BrookStreamFactory
(
);
// 'external' streams
static
const
std
::
string
AtomPositions
;
static
const
std
::
string
AtomVelocities
;
static
const
std
::
string
AtomForces
;
/**
* Create StreamImpl
*
* @param name stream name
* @param size stream size
* @param type data type (float, float2, ...)
* @param platform platform reference
* @param context context (currently ignored)
*
* @return StreamImpl
*/
StreamImpl
*
createStreamImpl
(
std
::
string
name
,
int
size
,
Stream
::
DataType
type
,
const
Platform
&
platform
,
OpenMMContextImpl
&
context
)
const
;
/**
* Get atom stream width
*
* @return atom stream width
*
*
*/
int
getDefaultAtomStreamWidth
(
void
)
const
;
/**
* Set atom stream width
*
* @param atomStreamWidth atom stream width
*
* @return DefaultReturnValue
*
* @throw OpenMMException if atomStreamWidth < 1
*
*/
int
setDefaultAtomStreamWidth
(
int
atomStreamWidth
);
/**
* Get randomNumber stream width
*
* @return randomNumber stream width
*
*
*/
int
getDefaultRandomNumberStreamWidth
(
void
)
const
;
/**
* Set randomNumber stream width
*
* @param randomNumberStreamWidth randomNumber stream width
*
* @return DefaultReturnValue
*
* @throw OpenMMException if randomNumberStreamWidth < 1
*
*/
int
setDefaultRandomNumberStreamWidth
(
int
randomNumberStreamWidth
);
/**
* Get randomNumber stream size
*
* @return randomNumber stream size
*
*
*/
int
getDefaultRandomNumberStreamSize
(
void
)
const
;
/**
* Set randomNumber stream size
*
* @param randomNumberStreamSize randomNumber stream size
*
* @return DefaultReturnValue
*
* @throw OpenMMException if randomNumberStreamSize < 1
*
*/
int
setDefaultRandomNumberStreamSize
(
int
randomNumberStreamSize
);
/**
* Get default dangle value
*
* @return default dangle value
*
*/
double
getDefaultDangleValue
(
void
)
const
;
/**
* Set default dangle value
*
* @param DefaultDangleValue default dangle value
*
* @return DefaultReturnValue
*
*/
int
setDefaultDangleValue
(
double
defaultDangleValue
);
private:
static
const
int
DefaultStreamAtomWidth
=
32
;
static
const
int
DefaultStreamRandomNumberWidth
=
32
;
static
const
int
DefaultStreamRandomNumberSize
=
1024
;
static
const
double
DefaultDangleValue
;
static
const
int
DefaultReturnValue
=
0
;
static
const
int
ErrorReturnValue
=
-
1
;
int
_defaultAtomStreamWidth
;
int
_defaultStreamRandomNumberWidth
;
int
_defaultStreamRandomNumberSize
;
double
_defaultDangleValue
;
};
}
// namespace OpenMM
...
...
platforms/brook/tests/CMakeLists.txt
View file @
10fc2f21
...
...
@@ -3,18 +3,46 @@
ENABLE_TESTING
()
SET
(
BROOK_SDK ../../../brook/sdk
)
SET
(
BROOK_SRC ../src
)
SET
(
BROOK_LIB brook_d
)
# ----------------------------------------------------------------------------
# SET(BROOK_GPU ../../../platforms/brook/src/gpu)
SET
(
BROOK_GPU C:\\cygwin\\home\\friedrim\\src\\openmm\\trunk\\OpenMM\\platforms\\brook\\src\\gpu
)
SET
(
BROOK_GPU_LIB gmxgpu_d
)
# logging
SET
(
LOG TRUE
)
IF
(
LOG
)
SET
(
LOG_FILE
"CMakeLog.txt"
)
FILE
(
WRITE
${
LOG_FILE
}
"In Brook Test Cmake
\n
"
)
# FILE( APPEND ${LOG_FILE} "BROOK_LIB_PATH=${BROOK_LIB_PATH}\n")
ENDIF
(
LOG
)
# ----------------------------------------------------------------------------
INCLUDE
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/../brook-cmake/FindBrook.cmake
)
# SET(BROOK_SRC ../src )
SET
(
BROOK_LIB brook
)
SET
(
OpenMM_BROOK_LIBRARY_NAME OpenMM_Brook
)
SET
(
SHARED_BROOK_TARGET
${
OpenMM_BROOK_LIBRARY_NAME
}
)
SET
(
STATIC_BROOK_TARGET
${
OpenMM_BROOK_LIBRARY_NAME
}
_static
)
# problem w/ brook.lib
IF
(
UNIX AND CMAKE_BUILD_TYPE MATCHES Debug
)
SET
(
SHARED_BROOK_TARGET
${
SHARED_BROOK_TARGET
}
_d
)
SET
(
STATIC_BROOK_TARGET
${
STATIC_BROOK_TARGET
}
_d
)
SET
(
BROOK_LIB
${
BROOK_LIB
}
_d
)
# ELSE(UNIX AND CMAKE_BUILD_TYPE MATCHES Debug)
# SET(BROOK_LIB ${BROOK_LIB}_d )
ENDIF
(
UNIX AND CMAKE_BUILD_TYPE MATCHES Debug
)
# Automatically create tests using files named "Test*.cpp"
FILE
(
GLOB TEST_PROGS
"*Test*.cpp"
)
FOREACH
(
TEST_PROG
${
TEST_PROGS
}
)
GET_FILENAME_COMPONENT
(
TEST_ROOT
${
TEST_PROG
}
NAME_WE
)
GET_FILENAME_COMPONENT
(
TEST_ROOT
${
TEST_PROG
}
NAME_WE
)
# Link with shared library
# ADD_EXECUTABLE(${TEST_ROOT} ${TEST_PROG})
...
...
@@ -22,175 +50,39 @@ FOREACH(TEST_PROG ${TEST_PROGS})
# TARGET_LINK_LIBRARIES(${TEST_ROOT} ${SHARED_TARGET} ${BROOK_LIB} )
# ADD_TEST(${TEST_ROOT} ${EXECUTABLE_OUTPUT_PATH}/${TEST_ROOT})
# Link with static library
SET
(
TEST_STATIC
${
TEST_ROOT
}
Static
)
LINK_DIRECTORIES
(
${
TEST_STATIC
}
${
BROOK_LIB_PATH
}
)
# STRING_APPEND( CMAKE_EXE_LINKER_FLAGS_DEBUG "/NODEFAULTLIB:\"LIBCMT.lib\"")
SET
(
CMAKE_EXE_LINKER_FLAGS_DEBUG
"/NODEFAULTLIB:
\"
LIBCMT.lib
\"
"
)
# SET( CMAKE_EXE_LINKER_FLAGS "/NODEFAULTLIB:\"LIBCMTD.lib\"")
ADD_EXECUTABLE
(
${
TEST_STATIC
}
${
TEST_PROG
}
)
ADD_DEFINITIONS
(
-D_WIN32
)
# Link with static library
SET
(
TEST_STATIC
${
TEST_ROOT
}
Static
)
LINK_DIRECTORIES
(
${
TEST_STATIC
}
${
BROOK_SDK
}
/lib
${
BROOK_GPU
}
)
# STRING_APPEND( CMAKE_EXE_LINKER_FLAGS_DEBUG "/NODEFAULTLIB:\"LIBCMT.lib\"")
SET
(
CMAKE_EXE_LINKER_FLAGS_DEBUG
"/NODEFAULTLIB:
\"
LIBCMT.lib
\"
"
)
ADD_EXECUTABLE
(
${
TEST_STATIC
}
${
TEST_PROG
}
)
INCLUDE_DIRECTORIES
(
BEFORE
${
BROOK_SRC
}
${
BROOK_GPU
}
)
ADD_DEFINITIONS
(
-D_WIN32
)
SET_TARGET_PROPERTIES
(
${
TEST_STATIC
}
SET_TARGET_PROPERTIES
(
${
TEST_STATIC
}
PROPERTIES
COMPILE_FLAGS
"-DOPENMM_USE_STATIC_LIBRARIES"
)
IF
(
CMAKE_BUILD_TYPE MATCHES Debug
)
TARGET_LINK_LIBRARIES
(
${
TEST_STATIC
}
${
STATIC_TARGET
}
${
BROOK_GPU_LIB
}
_d
${
BROOK_LIB
}
_d
)
ELSE
(
CMAKE_BUILD_TYPE MATCHES Debug
)
TARGET_LINK_LIBRARIES
(
${
TEST_STATIC
}
${
STATIC_TARGET
}
${
BROOK_GPU_LIB
}
${
BROOK_LIB
}
)
ENDIF
(
CMAKE_BUILD_TYPE MATCHES Debug
)
TARGET_LINK_LIBRARIES
(
${
TEST_STATIC
}
${
STATIC_TARGET
}
${
STATIC_BROOK_TARGET
}
${
BROOK_LIB
}
)
# ----------------------------------------------------------------------------
IF
(
LOG
)
FILE
(
APPEND
${
LOG_FILE
}
"TARGET_LINK_LIBRARIES:
${
TEST_STATIC
}
STATIC_TARGET=
${
STATIC_TARGET
}
STATIC_BROOK_TARGET=
${
STATIC_BROOK_TARGET
}
BROOK_LIB=
${
BROOK_LIB
}
\n
"
)
ENDIF
(
LOG
)
# ----------------------------------------------------------------------------
ADD_TEST
(
${
TEST_STATIC
}
${
EXECUTABLE_OUTPUT_PATH
}
/
${
TEST_STATIC
}
)
ENDFOREACH
(
TEST_PROG
${
TEST_PROGS
}
)
# - Look for the BrookGPU streaming extension to C language
#
# BROOK_FILE : .BR -> .CPP
# BROOK_INCLUDE_DIR : Include directory for Brook.hpp
# BROOK_C[XX]FLAGS : Flags needed to compile the produced CPP file
# BROOK_LIBRARIES : All needed libraries, including OpenGL for OGL backend
#
# Used internally :
# BROOK_CC : Location of BRCC
# BROOK_xxx_LIBRARY : Location of the various libraries used by brook
#
# BROOK_FILE code based on :
# http://www.vtk.org/Wiki/CMakeUserUseBison
#
# CUDA has a nice CMake file too, BTW :
#
#FIND_PATH(BROOK_INCLUDE_DIR "$ENV{BROOKROOT}/sdk/include" )
SET
(
BROOK_INCLUDE_DIR
"$ENV{BROOKROOT}
\\
sdk
\\
include"
)
SET
(
BROOK_CXXFLAGS
"-I
${
BROOK_INCLUDE_DIR
}
"
)
SET
(
BROOK_CFLAGS
"
${
BROOK_CXXFLAGS
}
"
)
FIND_PROGRAM
(
BROOK_CC brcc $ENV{BROOKROOT}/sdk/bin
)
# FIND_LIBRARY(BROOK_LIBRARIES NAMES brook PATHS ENV BROOKROOT PATH_SUFFIXES sdk/lib )
FIND_LIBRARY
(
BROOK_LIBRARIES brook PATHS $ENV{BROOKROOT}
"$ENV{BROOKROOT}/sdk/lib"
ENV BROOKROOT PATH_SUFFIXES sdk/lib
)
MESSAGE
(
STATUS
"
\n
********* In GpuBrook
${
BROOK_CC
}
<
${
BROOK_LIBRARIES
}
> incl=<
${
BROOK_INCLUDE_DIR
}
> *********
\n
"
)
# Search for all libraries
# - both BASE and RUNTIME TARGETS
# FOREACH(sub_lib brook ogl gpu-dx9 gpu-ctm gpu cpu GLEE)
#FOREACH(sub_lib brook gpu )
#
# # Look for lib
#
# FIND_LIBRARY(BROOK_${sub_lib}_LIBRARY
# NAMES
# ${sub_lib}
# PATHS
# "$ENV{BROOKROOT}"
# "$ENV{BROOKROOT}/sdk"
# "$ENV{BROOKROOT}/sdk/lib"
# PATH_SUFFIXES
# sdk
# sdk/lib
# )
#
# # if found, add to list
# IF (BROOK_${sub_lib}_LIBRARY)
# SET(BROOK_LIBRARIES ${BROOK_LIBRARIES} ${BROOK_${sub_lib}_LIBRARY})
# ELSE (BROOK_${sub_lib}_LIBRARY)
# MESSAGE(STATUS "\n********* X $ENV{BROOKROOT} <${sub_lib}> ${BROOK_${sub_lib}_LIBRARY} *********\n" )
# ENDIF (BROOK_${sub_lib}_LIBRARY)
#
# # all individual libs are advanced settings
# MARK_AS_ADVANCED(BROOK_${sub_lib}_LIBRARY)
#
#ENDFOREACH(sub_lib)
# SET(BROOK_brook_LIBRARY $ENV{BROOKROOT}/sdk/lib/brook/lib)
# MARK_AS_ADVANCED(BROOK_brook_LIBRARY)
# SET(BROOK_LIBRARIES ${BROOK_LIBRARIES} ${BROOK_brook_LIBRARY})
MESSAGE
(
STATUS
"
\n
********* In GpuBrook
${
BROOK_LIBRARIES
}
*********
\n
"
)
# Runtime target "OGL" requires OpenGL and GLU.
# IF (BROOK_ogl_LIBRARY)
# # OpenGL module
# IF(NOT OPENGL_FOUND)
# #INCLUDE(FindOpenGL)
# FIND_PACKAGE(OpenGL REQUIRED)
# ENDIF(NOT OPENGL_FOUND)
# # Add all OpenGL includes (which, in turn, may add X11 includes)
# IF (OPENGL_FOUND)
# SET (BROOK_LIBRARIES ${BROOK_LIBRARIES} ${OPENGL_LIBRARIES})
# ENDIF (OPENGL_FOUND)
#
# # NOTE: Old CMake used to have a separate FindGLU.cmake file
# ENDIF (BROOK_ogl_LIBRARY)
# Runtime target "CPU" can use OpenMP where available
#... not implemented yet...
# Runtime targets "GPU-DX9" and "GPU-CTM" need to be implemented too...
# GPU-DX9 : needs Microsoft DirectX9
# GPU-CTM : needs ATI's CTM (Note: will get deprecated by Brook+/CAL)
# check if includes and main lib are here
IF
(
BROOK_INCLUDE_DIR AND BROOK_brook_LIBRARY AND BROOK_CC
)
SET
(
BROOK_FOUND TRUE
)
# Implementation to allow interpreting/compiling Brook files
MACRO
(
BROOK_FILE FILENAME
)
# split input names
GET_FILENAME_COMPONENT
(
PATH
"
${
FILENAME
}
"
PATH
)
GET_FILENAME_COMPONENT
(
HEAD
"
${
FILENAME
}
"
NAME_WE
)
# without trailing ".BR"
# File names
SET
(
OUTPATH
"
${
CMAKE_CURRENT_BINARY_DIR
}
/
${
PATH
}
"
)
SET
(
BROOK_PREFIX
"
${
OUTPATH
}
/
${
HEAD
}
"
)
SET
(
OUTFILE
"
${
BROOK_PREFIX
}
.cpp"
)
# file produced by Brook
SET
(
INFILE
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
FILENAME
}
"
)
# canonical input name
# check output path
IF
(
NOT EXISTS
"
${
OUTPATH
}
"
)
FILE
(
MAKE_DIRECTORY
"
${
OUTPATH
}
"
)
ENDIF
(
NOT EXISTS
"
${
OUTPATH
}
"
)
# Run Brook
ADD_CUSTOM_COMMAND
(
OUTPUT
"
${
OUTFILE
}
"
COMMAND
"
${
BROOK_CC
}
"
ARGS
"-o
${
BROOK_PREFIX
}
"
"
${
INFILE
}
"
DEPENDS
"
${
INFILE
}
"
)
# Flag file as generated
SET_SOURCE_FILES_PROPERTIES
(
"
${
OUTFILE
}
"
PROPERTIES GENERATED TRUE
)
ENDMACRO
(
BROOK_FILE
)
ENDIF
(
BROOK_INCLUDE_DIR AND BROOK_brook_LIBRARY AND BROOK_CC
)
# Some verbosity
IF
(
BROOK_FOUND
)
IF
(
NOT BROOK_FIND_QUIETLY
)
MESSAGE
(
STATUS
"Found BROOK:
${
BROOK_CC
}
"
)
ENDIF
(
NOT BROOK_FIND_QUIETLY
)
ELSE
(
BROOK_FOUND
)
IF
(
BROOK_FIND_REQUIRED
)
MESSAGE
(
FATAL_ERROR
"Could not find BROOK"
)
ENDIF
(
BROOK_FIND_REQUIRED
)
ENDIF
(
BROOK_FOUND
)
# include_directories (${HELLO_SOURCE_DIR}/Hello)
#
# # Make sure the linker can find the Hello library once it is built.
# link_directories (${HELLO_BINARY_DIR}/Hello)
#
# # Add executable called "helloDemo" that is built from the source files
# # "demo.cxx" and "demo_b.cxx". The extensions are automatically found.
# add_executable (helloDemo demo.cxx demo_b.cxx)
#
# # Link the executable to the Hello library.
# target_link_libraries (helloDemo Hello)
#
# ----------------------------------------------------------------------------
IF
(
LOG
)
FILE
(
APPEND
${
LOG_FILE
}
"Leaving Brook Test Cmake
\n
"
)
ENDIF
(
LOG
)
# ----------------------------------------------------------------------------
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