Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pycuda
Manage
Activity
Members
Labels
Plan
Issues
1
Issue boards
Milestones
Wiki
Code
Merge requests
14
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Andreas Klöckner
pycuda
Commits
2fd81990
Commit
2fd81990
authored
16 years ago
by
Andreas Klöckner
Browse files
Options
Downloads
Patches
Plain Diff
Add SourceModule.
parent
c88bec96
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/python/driver.py
+34
-1
34 additions, 1 deletion
src/python/driver.py
with
34 additions
and
1 deletion
src/python/driver.py
+
34
−
1
View file @
2fd81990
...
...
@@ -16,6 +16,11 @@ def _add_functionality():
_add_functionality
()
def
pagelocked_zeros
(
shape
,
dtype
,
order
=
"
C
"
):
result
=
pagelocked_empty
(
shape
,
dtype
,
order
)
result
.
fill
(
0
)
...
...
@@ -24,4 +29,32 @@ def pagelocked_zeros(shape, dtype, order="C"):
_add_functionality
()
class
SourceModule
(
object
):
def
__init__
(
self
,
source
,
options
=
[],
keep
=
False
):
from
tempfile
import
mkdtemp
tempdir
=
mkdtemp
()
print
tempdir
from
os.path
import
join
outf
=
open
(
join
(
tempdir
,
"
kernel.cu
"
),
"
w
"
)
outf
.
write
(
source
)
outf
.
close
()
from
subprocess
import
call
result
=
call
([
"
nvcc
"
,
"
--cubin
"
]
+
options
+
[
"
kernel.cu
"
]
cwd
=
tempdir
)
data
=
open
(
join
(
tempdir
,
"
kernel.cubin
"
),
"
r
"
).
read
()
self
.
module
=
module_from_buffer
(
data
)
if
not
keep
:
from
os
import
listdir
,
unlink
,
rmdir
for
name
in
listdir
(
tempdir
):
os
.
unlink
(
join
(
tempdir
,
name
))
os
.
rmdir
(
tempdir
)
self
.
get_function
=
self
.
module
.
get_function
self
.
get_global
=
self
.
module
.
get_global
self
.
get_texref
=
self
.
module
.
get_texref
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment