Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pystencils_autodiff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
pycodegen
pystencils_autodiff
Commits
3df5aea3
Commit
3df5aea3
authored
5 years ago
by
Stephan Seitz
Browse files
Options
Downloads
Patches
Plain Diff
Only perform error check if wrapping CUDA functions
parent
67d7f4ae
No related branches found
No related tags found
No related merge requests found
Pipeline
#19332
failed
5 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/pystencils_autodiff/framework_integration/astnodes.py
+10
-7
10 additions, 7 deletions
src/pystencils_autodiff/framework_integration/astnodes.py
with
10 additions
and
7 deletions
src/pystencils_autodiff/framework_integration/astnodes.py
+
10
−
7
View file @
3df5aea3
...
@@ -156,10 +156,12 @@ def generate_kernel_call(kernel_function):
...
@@ -156,10 +156,12 @@ def generate_kernel_call(kernel_function):
KernelFunctionCall
(
kernel_function
),
KernelFunctionCall
(
kernel_function
),
CudaErrorCheck
(),
CudaErrorCheck
(),
])
])
el
se
:
el
if
kernel_function
.
backend
==
'
gpucuda
'
:
return
pystencils
.
astnodes
.
Block
([
CudaErrorCheck
(),
return
pystencils
.
astnodes
.
Block
([
CudaErrorCheck
(),
KernelFunctionCall
(
kernel_function
),
KernelFunctionCall
(
kernel_function
),
CudaErrorCheck
()])
CudaErrorCheck
()])
else
:
return
pystencils
.
astnodes
.
Block
([
KernelFunctionCall
(
kernel_function
)])
return
block
return
block
...
@@ -236,8 +238,8 @@ class CudaErrorCheckDefinition(CustomCodeNode):
...
@@ -236,8 +238,8 @@ class CudaErrorCheckDefinition(CustomCodeNode):
function_name
=
'
gpuErrchk
'
function_name
=
'
gpuErrchk
'
code
=
"""
code
=
"""
#
ifdef __GNUC__
#ifdef __GNUC__
#
define gpuErrchk(ans) { gpuAssert((ans), __PRETTY_FUNCTION__, __FILE__, __LINE__); }
#define gpuErrchk(ans) { gpuAssert((ans), __PRETTY_FUNCTION__, __FILE__, __LINE__); }
inline static void gpuAssert(cudaError_t code, const char* function, const char *file, int line, bool abort=true)
inline static void gpuAssert(cudaError_t code, const char* function, const char *file, int line, bool abort=true)
{
{
if (code != cudaSuccess)
if (code != cudaSuccess)
...
@@ -246,8 +248,8 @@ inline static void gpuAssert(cudaError_t code, const char* function, const char
...
@@ -246,8 +248,8 @@ inline static void gpuAssert(cudaError_t code, const char* function, const char
if (abort) exit(code);
if (abort) exit(code);
}
}
}
}
#
else
#else
#
define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); }
#define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); }
inline static void gpuAssert(cudaError_t code, const char* function, const char *file, int line, bool abort=true)
inline static void gpuAssert(cudaError_t code, const char* function, const char *file, int line, bool abort=true)
{
{
if (code != cudaSuccess)
if (code != cudaSuccess)
...
@@ -256,9 +258,9 @@ inline static void gpuAssert(cudaError_t code, const char* function, const char
...
@@ -256,9 +258,9 @@ inline static void gpuAssert(cudaError_t code, const char* function, const char
if (abort) exit(code);
if (abort) exit(code);
}
}
}
}
#
endif
#endif
"""
"""
headers
=
'
<cuda.h>
'
headers
=
[
'
<cuda.h>
'
]
class
CudaErrorCheck
(
CustomCodeNode
):
class
CudaErrorCheck
(
CustomCodeNode
):
...
@@ -288,3 +290,4 @@ class CudaErrorCheck(CustomCodeNode):
...
@@ -288,3 +290,4 @@ class CudaErrorCheck(CustomCodeNode):
err_check_function
=
CudaErrorCheckDefinition
()
err_check_function
=
CudaErrorCheckDefinition
()
required_global_declarations
=
[
err_check_function
]
required_global_declarations
=
[
err_check_function
]
headers
=
[
'
<cuda.h>
'
]
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