-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #240 from fixstars/185-add-carray-cindexer-test-fo…
…r-ultima Add CArray and CIndexer Tests for Ultima
- Loading branch information
Showing
3 changed files
with
140 additions
and
1 deletion.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
tests/clpy_tests/opencl_tests/ultima_tests/test_cindexer.py
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# flake8: noqa | ||
# TODO(vorj): When we will meet flake8 3.7.0+, | ||
# we should ignore only W291 for whole file | ||
# using --per-file-ignores . | ||
|
||
import unittest | ||
import utility | ||
|
||
|
||
class TestUltimaCIndexer(unittest.TestCase): | ||
|
||
def test_cindexer_argument_mutation(self): | ||
x = utility.exec_ultima('', _clpy_header='#include <cupy/carray.hpp>') + ''' | ||
void f(CIndexer_2 ind) | ||
{ | ||
} | ||
'''[1:] | ||
y = utility.exec_ultima( | ||
''' | ||
void f(CIndexer<2> ind){} | ||
''', | ||
_clpy_header='#include <cupy/carray.hpp>') | ||
self.maxDiff = None | ||
self.assertEqual(x, y) | ||
|
||
def test_cindexer_member_function(self): | ||
x = utility.exec_ultima('', _clpy_header='#include <cupy/carray.hpp>') + ''' | ||
void f(CIndexer_2 ind) | ||
{ | ||
ind_size; | ||
} | ||
'''[1:] | ||
y = utility.exec_ultima( | ||
''' | ||
void f(CIndexer<2> ind){ | ||
ind.size(); | ||
} | ||
''', | ||
_clpy_header='#include <cupy/carray.hpp>') | ||
self.maxDiff = None | ||
self.assertEqual(x, y) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
91 changes: 91 additions & 0 deletions
91
tests/clpy_tests/opencl_tests/ultima_tests/test_ultima_carray.py
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 |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# flake8: noqa | ||
# TODO(vorj): When we will meet flake8 3.7.0+, | ||
# we should ignore only W291 for whole file | ||
# using --per-file-ignores . | ||
|
||
import unittest | ||
import utility | ||
|
||
|
||
class TestUltimaCArray(unittest.TestCase): | ||
|
||
def test_carray_argument_mutation(self): | ||
x = utility.exec_ultima('', _clpy_header='#include <cupy/carray.hpp>') + ''' | ||
void f(__global int* const __restrict__ arr, const CArray_2 arr_info) | ||
{ | ||
} | ||
'''[1:] | ||
y = utility.exec_ultima( | ||
''' | ||
void f(CArray<int, 2> arr){} | ||
''', | ||
_clpy_header='#include <cupy/carray.hpp>') | ||
self.maxDiff = None | ||
self.assertEqual(x, y) | ||
|
||
def test_carray_member_function(self): | ||
x = utility.exec_ultima('', _clpy_header='#include <cupy/carray.hpp>') + ''' | ||
void f(__global int* const __restrict__ arr, const CArray_2 arr_info) | ||
{ | ||
((const size_t)arr_info.size_); | ||
((const size_t*)arr_info.shape_); | ||
((const size_t*)arr_info.strides_); | ||
} | ||
'''[1:] | ||
y = utility.exec_ultima( | ||
''' | ||
void f(CArray<int, 2> arr){ | ||
arr.size(); | ||
arr.shape(); | ||
arr.strides(); | ||
} | ||
''', | ||
_clpy_header='#include <cupy/carray.hpp>') | ||
self.maxDiff = None | ||
self.assertEqual(x, y) | ||
|
||
def test_carray_0_member_function(self): | ||
x = utility.exec_ultima('', _clpy_header='#include <cupy/carray.hpp>') + ''' | ||
void f(__global int* const __restrict__ arr, const CArray_0 arr_info) | ||
{ | ||
((const size_t)arr_info.size_); | ||
((const size_t*)NULL); | ||
((const size_t*)NULL); | ||
} | ||
'''[1:] | ||
y = utility.exec_ultima( | ||
''' | ||
void f(CArray<int, 0> arr){ | ||
arr.size(); | ||
arr.shape(); | ||
arr.strides(); | ||
} | ||
''', | ||
_clpy_header='#include <cupy/carray.hpp>') | ||
self.maxDiff = None | ||
self.assertEqual(x, y) | ||
|
||
def test_carray_1_member_function(self): | ||
x = utility.exec_ultima('', _clpy_header='#include <cupy/carray.hpp>') + ''' | ||
void f(__global int* const __restrict__ arr, const CArray_1 arr_info) | ||
{ | ||
((const size_t)arr_info.size_); | ||
((const size_t*)&arr_info.shape_); | ||
((const size_t*)&arr_info.strides_); | ||
} | ||
'''[1:] | ||
y = utility.exec_ultima( | ||
''' | ||
void f(CArray<int, 1> arr){ | ||
arr.size(); | ||
arr.shape(); | ||
arr.strides(); | ||
} | ||
''', | ||
_clpy_header='#include <cupy/carray.hpp>') | ||
self.maxDiff = None | ||
self.assertEqual(x, y) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
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