-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
compiler: Uncache data carriers #1913
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f8cac40
compiler: Enforce uniqueness of Objects
FabioLuporini b969bf1
compiler: Introduce Uncached, for unique objects
FabioLuporini 6320596
compiler: Patch DataSymbol pickling once Uncached
FabioLuporini 5b9adbe
examples: Update expected output once Uncached
FabioLuporini File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from ctypes import byref, c_void_p | ||
import weakref | ||
|
||
import numpy as np | ||
|
@@ -7,7 +8,8 @@ | |
ConditionalDimension, SubDimension, Constant, Operator, Eq, Dimension, | ||
DefaultDimension, _SymbolCache, clear_cache, solve, VectorFunction, | ||
TensorFunction, TensorTimeFunction, VectorTimeFunction) | ||
from devito.types import Scalar, Symbol, NThreadsBase, DeviceID, NPThreads, ThreadID | ||
from devito.types import (DeviceID, NThreadsBase, NPThreads, Object, Scalar, Symbol, | ||
ThreadID) | ||
|
||
|
||
@pytest.fixture | ||
|
@@ -168,6 +170,28 @@ def test_bound_symbol(self): | |
assert hash(u0._C_symbol) != hash(u1._C_symbol) | ||
assert u0._C_symbol != u1._C_symbol | ||
|
||
def test_objects(self): | ||
v0 = byref(c_void_p(3)) | ||
v1 = byref(c_void_p(4)) | ||
|
||
dtype = type('Bar', (c_void_p,), {}) | ||
|
||
foo0 = Object('foo', dtype, v0) | ||
foo1 = Object('foo', dtype, v0) | ||
foo2 = Object('foo', dtype, v1) | ||
|
||
# Obviously: | ||
assert foo0 is not foo1 | ||
assert foo0 is not foo2 | ||
assert foo1 is not foo2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should the dtype and value be checked too for safety? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "checked" how? like |
||
|
||
# Carried value doesn't matter -- an Object is always unique | ||
assert hash(foo0) != hash(foo1) | ||
|
||
# And obviously: | ||
assert hash(foo0) != hash(foo2) | ||
assert hash(foo1) != hash(foo2) | ||
|
||
|
||
class TestCaching(object): | ||
|
||
|
@@ -358,7 +382,7 @@ def test_default_dimension(self): | |
assert dd0 is not dd1 | ||
|
||
def test_constant_new(self): | ||
"""Test that new u[x, y] instances don't cache""" | ||
"""Test that new Constant instances don't cache.""" | ||
u0 = Constant(name='u') | ||
u0.data = 6. | ||
u1 = Constant(name='u') | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change of order deterministic?