FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
arrayfire-python/arrayfire/cuda.py at v3.5 · arrayfire/arrayfire-python · GitHub
arrayfire
arrayfire-python
Repository navigation
Code
Issues
57
(57)
Pull requests
3
(3)
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
arrayfire-python
/
arrayfire
/
cuda.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
87 lines (65 loc) · 2.02 KB
Breadcrumbs
arrayfire-python
/
arrayfire
/
cuda.py
Copy path
File metadata and controls
87 lines (65 loc) · 2.02 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#######################################################
# Copyright (c) 2015, ArrayFire
# All rights reserved.
#
# This file is distributed under 3-clause BSD license.
# The complete license agreement can be obtained at:
# http://arrayfire.com/licenses/BSD-3-Clause
########################################################
"""
Functions specific to CUDA backend.
This module provides interoperability with other CUDA libraries.
"""
def
get_stream
(
idx
):
"""
Get the CUDA stream used for the device `idx` by ArrayFire.
Parameters
----------
idx : int.
Specifies the index of the device.
Returns
-----------
stream : integer denoting the stream id.
"""
import
ctypes
as
ct
from
.
util
import
safe_call
as
safe_call
from
.
library
import
backend
as
backend
if
(
backend
.
name
()
!=
"cuda"
):
raise
RuntimeError
(
"Invalid backend loaded"
)
stream
=
c_void_ptr_t
(
0
)
safe_call
(
backend
.
get
().
afcu_get_stream
(
c_pointer
(
stream
),
idx
))
return
stream
.
value
def
get_native_id
(
idx
):
"""
Get native (unsorted) CUDA device ID
Parameters
----------
idx : int.
Specifies the (sorted) index of the device.
Returns
-----------
native_idx : integer denoting the native cuda id.
"""
import
ctypes
as
ct
from
.
util
import
safe_call
as
safe_call
from
.
library
import
backend
as
backend
if
(
backend
.
name
()
!=
"cuda"
):
raise
RuntimeError
(
"Invalid backend loaded"
)
native
=
c_int_t
(
0
)
safe_call
(
backend
.
get
().
afcu_get_native_id
(
c_pointer
(
native
),
idx
))
return
native
.
value
def
set_native_id
(
idx
):
"""
Set native (unsorted) CUDA device ID
Parameters
----------
idx : int.
Specifies the (unsorted) native index of the device.
"""
import
ctypes
as
ct
from
.
util
import
safe_call
as
safe_call
from
.
library
import
backend
as
backend
if
(
backend
.
name
()
!=
"cuda"
):
raise
RuntimeError
(
"Invalid backend loaded"
)
safe_call
(
backend
.
get
().
afcu_set_native_id
(
idx
))
return
Back
|
FazBrowse Home
|
New Git URL