Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tic
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wenyuanbo
tic
Commits
c7e7e7f5
Commit
c7e7e7f5
authored
Apr 20, 2018
by
Yida Wang
Committed by
Tianqi Chen
Apr 20, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add two more device properties (#1124)
parent
202570e4
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
55 additions
and
2 deletions
+55
-2
include/tvm/runtime/device_api.h
+3
-1
python/tvm/_ffi/runtime_ctypes.py
+12
-0
src/runtime/cuda/cuda_device_api.cc
+10
-0
src/runtime/metal/metal_device_api.mm
+2
-0
src/runtime/opencl/opencl_device_api.cc
+21
-0
src/runtime/opencl/opencl_module.cc
+1
-1
src/runtime/opengl/opengl_device_api.cc
+2
-0
src/runtime/rocm/rocm_device_api.cc
+2
-0
src/runtime/vulkan/vulkan_device_api.cc
+2
-0
No files found.
include/tvm/runtime/device_api.h
View file @
c7e7e7f5
...
...
@@ -21,7 +21,9 @@ enum DeviceAttrKind : int {
kWarpSize
=
2
,
kMaxSharedMemoryPerBlock
=
3
,
kComputeVersion
=
4
,
kDeviceName
=
5
kDeviceName
=
5
,
kMaxClockRate
=
6
,
kMultiProcessorCount
=
7
};
/*! \brief Number of bytes each allocation must align to */
...
...
python/tvm/_ffi/runtime_ctypes.py
View file @
c7e7e7f5
...
...
@@ -166,6 +166,18 @@ class TVMContext(ctypes.Structure):
return
_api_internal
.
_GetDeviceAttr
(
self
.
device_type
,
self
.
device_id
,
5
)
@property
def
max_clock_rate
(
self
):
"""Return the max clock frequency of device."""
return
_api_internal
.
_GetDeviceAttr
(
self
.
device_type
,
self
.
device_id
,
6
)
@property
def
multi_processor_count
(
self
):
"""Return the number of compute units of device."""
return
_api_internal
.
_GetDeviceAttr
(
self
.
device_type
,
self
.
device_id
,
7
)
def
sync
(
self
):
"""Synchronize until jobs finished at the context."""
check_call
(
_LIB
.
TVMSynchronize
(
self
.
device_type
,
self
.
device_id
,
None
))
...
...
src/runtime/cuda/cuda_device_api.cc
View file @
c7e7e7f5
...
...
@@ -62,6 +62,16 @@ class CUDADeviceAPI final : public DeviceAPI {
*
rv
=
std
::
string
(
props
.
name
);
return
;
}
case
kMaxClockRate
:
{
CUDA_CALL
(
cudaDeviceGetAttribute
(
&
value
,
cudaDevAttrClockRate
,
ctx
.
device_id
));
break
;
}
case
kMultiProcessorCount
:
{
CUDA_CALL
(
cudaDeviceGetAttribute
(
&
value
,
cudaDevAttrMultiProcessorCount
,
ctx
.
device_id
));
break
;
}
}
*
rv
=
value
;
}
...
...
src/runtime/metal/metal_device_api.mm
View file @
c7e7e7f5
...
...
@@ -42,6 +42,8 @@ void MetalWorkspace::GetAttr(
case kMaxSharedMemoryPerBlock: return;
case kComputeVersion: return;
case kDeviceName: return;
case kMaxClockRate: return;
case kMultiProcessorCount: return;
case kExist: break;
}
}
...
...
src/runtime/opencl/opencl_device_api.cc
View file @
c7e7e7f5
...
...
@@ -42,6 +42,11 @@ void OpenCLWorkspace::GetAttr(
break
;
}
case
kWarpSize
:
{
/* TODO: the warp size of OpenCL device is not always 1
e.g. Intel GPU has a sub group concept which contains 8 - 32 work items,
corresponding to the number of SIMD entries the heardware configures.
We need to figure out a way to query this information from the hardware.
*/
*
rv
=
1
;
break
;
}
...
...
@@ -62,6 +67,22 @@ void OpenCLWorkspace::GetAttr(
*
rv
=
std
::
string
(
value
);
break
;
}
case
kMaxClockRate
:
{
cl_uint
value
;
OPENCL_CALL
(
clGetDeviceInfo
(
devices
[
index
],
CL_DEVICE_MAX_CLOCK_FREQUENCY
,
sizeof
(
cl_uint
),
&
value
,
nullptr
));
*
rv
=
static_cast
<
int32_t
>
(
value
);
break
;
}
case
kMultiProcessorCount
:
{
cl_uint
value
;
OPENCL_CALL
(
clGetDeviceInfo
(
devices
[
index
],
CL_DEVICE_MAX_COMPUTE_UNITS
,
sizeof
(
cl_uint
),
&
value
,
nullptr
));
*
rv
=
static_cast
<
int32_t
>
(
value
);
break
;
}
case
kExist
:
break
;
}
}
...
...
src/runtime/opencl/opencl_module.cc
View file @
c7e7e7f5
...
...
@@ -176,7 +176,7 @@ class OpenCLModuleNode : public ModuleNode {
class
OpenCLWrappedFunc
{
public
:
// initialize the
CUDA
function.
// initialize the
OpenCL
function.
void
Init
(
OpenCLModuleNode
*
m
,
std
::
shared_ptr
<
ModuleNode
>
sptr
,
OpenCLModuleNode
::
KTRefEntry
entry
,
...
...
src/runtime/opengl/opengl_device_api.cc
View file @
c7e7e7f5
...
...
@@ -98,6 +98,8 @@ void OpenGLWorkspace::GetAttr(
break
;
}
case
kDeviceName
:
return
;
case
kMaxClockRate
:
return
;
case
kMultiProcessorCount
:
return
;
}
}
...
...
src/runtime/rocm/rocm_device_api.cc
View file @
c7e7e7f5
...
...
@@ -52,6 +52,8 @@ class ROCMDeviceAPI final : public DeviceAPI {
return
;
}
case
kDeviceName
:
return
;
case
kMaxClockRate
:
return
;
case
kMultiProcessorCount
:
return
;
}
*
rv
=
value
;
}
...
...
src/runtime/vulkan/vulkan_device_api.cc
View file @
c7e7e7f5
...
...
@@ -74,6 +74,8 @@ void VulkanWorkspace::GetAttr(
break
;
}
case
kDeviceName
:
return
;
case
kMaxClockRate
:
return
;
case
kMultiProcessorCount
:
return
;
case
kExist
:
break
;
}
}
...
...
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