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
0f83704f
Commit
0f83704f
authored
Mar 28, 2013
by
Peter Eastman
Browse files
Added platform properties to report the CUDA/OpenCL device name and OpenCL platform name
parent
4d75af9f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
10 deletions
+57
-10
platforms/cuda/include/CudaPlatform.h
platforms/cuda/include/CudaPlatform.h
+7
-0
platforms/cuda/src/CudaPlatform.cpp
platforms/cuda/src/CudaPlatform.cpp
+20
-5
platforms/opencl/include/OpenCLPlatform.h
platforms/opencl/include/OpenCLPlatform.h
+14
-0
platforms/opencl/src/OpenCLPlatform.cpp
platforms/opencl/src/OpenCLPlatform.cpp
+16
-5
No files found.
platforms/cuda/include/CudaPlatform.h
View file @
0f83704f
...
@@ -62,6 +62,13 @@ public:
...
@@ -62,6 +62,13 @@ public:
static
const
std
::
string
key
=
"CudaDeviceIndex"
;
static
const
std
::
string
key
=
"CudaDeviceIndex"
;
return
key
;
return
key
;
}
}
/**
* This is the name of the parameter that reports the CUDA device or devices being used.
*/
static
const
std
::
string
&
CudaDeviceName
()
{
static
const
std
::
string
key
=
"CudaDeviceName"
;
return
key
;
}
/**
/**
* This is the name of the parameter for selecting whether CUDA should sync or spin loop while waiting for results.
* This is the name of the parameter for selecting whether CUDA should sync or spin loop while waiting for results.
*/
*/
...
...
platforms/cuda/src/CudaPlatform.cpp
View file @
0f83704f
...
@@ -42,6 +42,13 @@
...
@@ -42,6 +42,13 @@
using
namespace
OpenMM
;
using
namespace
OpenMM
;
using
namespace
std
;
using
namespace
std
;
#define CHECK_RESULT(result, prefix) \
if (result != CUDA_SUCCESS) { \
std::stringstream m; \
m<<prefix<<": "<<CudaContext::getErrorString(result)<<" ("<<result<<")"<<" at "<<__FILE__<<":"<<__LINE__; \
throw OpenMMException(m.str());\
}
extern
"C"
OPENMM_EXPORT_CUDA
void
registerPlatforms
()
{
extern
"C"
OPENMM_EXPORT_CUDA
void
registerPlatforms
()
{
Platform
::
registerPlatform
(
new
CudaPlatform
());
Platform
::
registerPlatform
(
new
CudaPlatform
());
}
}
...
@@ -77,11 +84,13 @@ CudaPlatform::CudaPlatform() {
...
@@ -77,11 +84,13 @@ CudaPlatform::CudaPlatform() {
registerKernelFactory
(
ApplyMonteCarloBarostatKernel
::
Name
(),
factory
);
registerKernelFactory
(
ApplyMonteCarloBarostatKernel
::
Name
(),
factory
);
registerKernelFactory
(
RemoveCMMotionKernel
::
Name
(),
factory
);
registerKernelFactory
(
RemoveCMMotionKernel
::
Name
(),
factory
);
platformProperties
.
push_back
(
CudaDeviceIndex
());
platformProperties
.
push_back
(
CudaDeviceIndex
());
platformProperties
.
push_back
(
CudaDeviceName
());
platformProperties
.
push_back
(
CudaUseBlockingSync
());
platformProperties
.
push_back
(
CudaUseBlockingSync
());
platformProperties
.
push_back
(
CudaPrecision
());
platformProperties
.
push_back
(
CudaPrecision
());
platformProperties
.
push_back
(
CudaCompiler
());
platformProperties
.
push_back
(
CudaCompiler
());
platformProperties
.
push_back
(
CudaTempDirectory
());
platformProperties
.
push_back
(
CudaTempDirectory
());
setPropertyDefaultValue
(
CudaDeviceIndex
(),
""
);
setPropertyDefaultValue
(
CudaDeviceIndex
(),
""
);
setPropertyDefaultValue
(
CudaDeviceName
(),
""
);
setPropertyDefaultValue
(
CudaUseBlockingSync
(),
"true"
);
setPropertyDefaultValue
(
CudaUseBlockingSync
(),
"true"
);
setPropertyDefaultValue
(
CudaPrecision
(),
"single"
);
setPropertyDefaultValue
(
CudaPrecision
(),
"single"
);
#ifdef _MSC_VER
#ifdef _MSC_VER
...
@@ -161,13 +170,19 @@ CudaPlatform::PlatformData::PlatformData(const System& system, const string& dev
...
@@ -161,13 +170,19 @@ CudaPlatform::PlatformData::PlatformData(const System& system, const string& dev
}
}
if
(
contexts
.
size
()
==
0
)
if
(
contexts
.
size
()
==
0
)
contexts
.
push_back
(
new
CudaContext
(
system
,
-
1
,
blocking
,
precisionProperty
,
compilerProperty
,
tempProperty
,
*
this
));
contexts
.
push_back
(
new
CudaContext
(
system
,
-
1
,
blocking
,
precisionProperty
,
compilerProperty
,
tempProperty
,
*
this
));
stringstream
device
;
stringstream
device
Index
,
deviceName
;
for
(
int
i
=
0
;
i
<
(
int
)
contexts
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
(
int
)
contexts
.
size
();
i
++
)
{
if
(
i
>
0
)
if
(
i
>
0
)
{
device
<<
','
;
deviceIndex
<<
','
;
device
<<
contexts
[
i
]
->
getDeviceIndex
();
deviceName
<<
','
;
}
deviceIndex
<<
contexts
[
i
]
->
getDeviceIndex
();
char
name
[
1000
];
CHECK_RESULT
(
cuDeviceGetName
(
name
,
1000
,
contexts
[
i
]
->
getDevice
()),
"Error querying device name"
);
deviceName
<<
name
;
}
}
propertyValues
[
CudaPlatform
::
CudaDeviceIndex
()]
=
device
.
str
();
propertyValues
[
CudaPlatform
::
CudaDeviceIndex
()]
=
deviceIndex
.
str
();
propertyValues
[
CudaPlatform
::
CudaDeviceName
()]
=
deviceName
.
str
();
propertyValues
[
CudaPlatform
::
CudaUseBlockingSync
()]
=
blocking
?
"true"
:
"false"
;
propertyValues
[
CudaPlatform
::
CudaUseBlockingSync
()]
=
blocking
?
"true"
:
"false"
;
propertyValues
[
CudaPlatform
::
CudaPrecision
()]
=
precisionProperty
;
propertyValues
[
CudaPlatform
::
CudaPrecision
()]
=
precisionProperty
;
propertyValues
[
CudaPlatform
::
CudaCompiler
()]
=
compilerProperty
;
propertyValues
[
CudaPlatform
::
CudaCompiler
()]
=
compilerProperty
;
...
...
platforms/opencl/include/OpenCLPlatform.h
View file @
0f83704f
...
@@ -61,6 +61,13 @@ public:
...
@@ -61,6 +61,13 @@ public:
static
const
std
::
string
key
=
"OpenCLDeviceIndex"
;
static
const
std
::
string
key
=
"OpenCLDeviceIndex"
;
return
key
;
return
key
;
}
}
/**
* This is the name of the parameter that reports the OpenCL device or devices being used.
*/
static
const
std
::
string
&
OpenCLDeviceName
()
{
static
const
std
::
string
key
=
"OpenCLDeviceName"
;
return
key
;
}
/**
/**
* This is the name of the parameter for selecting which OpenCL platform to use.
* This is the name of the parameter for selecting which OpenCL platform to use.
*/
*/
...
@@ -68,6 +75,13 @@ public:
...
@@ -68,6 +75,13 @@ public:
static
const
std
::
string
key
=
"OpenCLPlatformIndex"
;
static
const
std
::
string
key
=
"OpenCLPlatformIndex"
;
return
key
;
return
key
;
}
}
/**
* This is the name of the parameter that reports the OpenCL platform being used.
*/
static
const
std
::
string
&
OpenCLPlatformName
()
{
static
const
std
::
string
key
=
"OpenCLPlatformName"
;
return
key
;
}
/**
/**
* This is the name of the parameter for selecting what numerical precision to use.
* This is the name of the parameter for selecting what numerical precision to use.
*/
*/
...
...
platforms/opencl/src/OpenCLPlatform.cpp
View file @
0f83704f
...
@@ -74,10 +74,14 @@ OpenCLPlatform::OpenCLPlatform() {
...
@@ -74,10 +74,14 @@ OpenCLPlatform::OpenCLPlatform() {
registerKernelFactory
(
ApplyMonteCarloBarostatKernel
::
Name
(),
factory
);
registerKernelFactory
(
ApplyMonteCarloBarostatKernel
::
Name
(),
factory
);
registerKernelFactory
(
RemoveCMMotionKernel
::
Name
(),
factory
);
registerKernelFactory
(
RemoveCMMotionKernel
::
Name
(),
factory
);
platformProperties
.
push_back
(
OpenCLDeviceIndex
());
platformProperties
.
push_back
(
OpenCLDeviceIndex
());
platformProperties
.
push_back
(
OpenCLDeviceName
());
platformProperties
.
push_back
(
OpenCLPlatformIndex
());
platformProperties
.
push_back
(
OpenCLPlatformIndex
());
platformProperties
.
push_back
(
OpenCLPlatformName
());
platformProperties
.
push_back
(
OpenCLPrecision
());
platformProperties
.
push_back
(
OpenCLPrecision
());
setPropertyDefaultValue
(
OpenCLDeviceIndex
(),
""
);
setPropertyDefaultValue
(
OpenCLDeviceIndex
(),
""
);
setPropertyDefaultValue
(
OpenCLDeviceName
(),
""
);
setPropertyDefaultValue
(
OpenCLPlatformIndex
(),
""
);
setPropertyDefaultValue
(
OpenCLPlatformIndex
(),
""
);
setPropertyDefaultValue
(
OpenCLPlatformName
(),
""
);
setPropertyDefaultValue
(
OpenCLPrecision
(),
"single"
);
setPropertyDefaultValue
(
OpenCLPrecision
(),
"single"
);
}
}
...
@@ -133,14 +137,21 @@ OpenCLPlatform::PlatformData::PlatformData(const System& system, const string& p
...
@@ -133,14 +137,21 @@ OpenCLPlatform::PlatformData::PlatformData(const System& system, const string& p
}
}
if
(
contexts
.
size
()
==
0
)
if
(
contexts
.
size
()
==
0
)
contexts
.
push_back
(
new
OpenCLContext
(
system
,
platformIndex
,
-
1
,
precisionProperty
,
*
this
));
contexts
.
push_back
(
new
OpenCLContext
(
system
,
platformIndex
,
-
1
,
precisionProperty
,
*
this
));
stringstream
device
;
stringstream
device
Index
,
deviceName
;
for
(
int
i
=
0
;
i
<
(
int
)
contexts
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
(
int
)
contexts
.
size
();
i
++
)
{
if
(
i
>
0
)
if
(
i
>
0
)
{
device
<<
','
;
device
Index
<<
','
;
device
<<
contexts
[
i
]
->
getDeviceIndex
()
;
device
Name
<<
','
;
}
}
propertyValues
[
OpenCLPlatform
::
OpenCLDeviceIndex
()]
=
device
.
str
();
deviceIndex
<<
contexts
[
i
]
->
getDeviceIndex
();
deviceName
<<
contexts
[
i
]
->
getDevice
().
getInfo
<
CL_DEVICE_NAME
>
();
}
propertyValues
[
OpenCLPlatform
::
OpenCLDeviceIndex
()]
=
deviceIndex
.
str
();
propertyValues
[
OpenCLPlatform
::
OpenCLDeviceName
()]
=
deviceName
.
str
();
propertyValues
[
OpenCLPlatform
::
OpenCLPlatformIndex
()]
=
contexts
[
0
]
->
intToString
(
platformIndex
);
propertyValues
[
OpenCLPlatform
::
OpenCLPlatformIndex
()]
=
contexts
[
0
]
->
intToString
(
platformIndex
);
std
::
vector
<
cl
::
Platform
>
platforms
;
cl
::
Platform
::
get
(
&
platforms
);
propertyValues
[
OpenCLPlatform
::
OpenCLPlatformName
()]
=
platforms
[
platformIndex
].
getInfo
<
CL_PLATFORM_NAME
>
();
propertyValues
[
OpenCLPlatform
::
OpenCLPrecision
()]
=
precisionProperty
;
propertyValues
[
OpenCLPlatform
::
OpenCLPrecision
()]
=
precisionProperty
;
contextEnergy
.
resize
(
contexts
.
size
());
contextEnergy
.
resize
(
contexts
.
size
());
}
}
...
...
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