Skip to content

Commit

Permalink
Merge pull request #20 from cristianrcv/19-unittest-fails
Browse files Browse the repository at this point in the history
BUG: Unittest failures
  • Loading branch information
cristianrcv authored Aug 26, 2020
2 parents b01f48c + 7d04f20 commit 3169c7f
Show file tree
Hide file tree
Showing 4 changed files with 151 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pycompss/api/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ def _clean(list_of_files):

class TestParallelDecorator(unittest.TestCase):

def test_decorator(self):
def _test_decorator(self):
# Base variables
import os
dir_path = os.path.dirname(os.path.realpath(__file__))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
# [COMPSs Autoparallel] Begin Autogenerated code
import math

from pycompss.api.api import compss_barrier, compss_wait_on, compss_open
from pycompss.api.task import task
from pycompss.api.parameter import *


@task(t3=IN, m_size=IN, t2=IN, beta=IN, c={Type: COLLECTION_INOUT, Depth: 2})
def LT3(t3, m_size, t2, beta, c):
for t4 in range(2 * t3, min(m_size - 1, 2 * t3 + 1) + 1):
lbv = 2 * t2
ubv = min(m_size - 1, 2 * t2 + 1)
for t5 in range(2 * t2, min(m_size - 1, 2 * t2 + 1) + 1):
c[t5 - 2 * t2][t4 - 2 * t3] = S1_no_task(c[t5 - 2 * t2][t4 - 2 * t3], beta)


@task(t3=IN, m_size=IN, t4=IN, t2=IN, alpha=IN, a={Type: COLLECTION_IN, Depth: 2}, b={Type: COLLECTION_IN, Depth: 2}, c={Type: COLLECTION_INOUT, Depth: 2})
def LT4(t3, m_size, t4, t2, alpha, a, b, c):
for t5 in range(2 * t3, min(m_size - 1, 2 * t3 + 1) + 1):
lbp = 2 * t4
ubp = min(m_size - 1, 2 * t4 + 1)
for t6 in range(2 * t4, min(m_size - 1, 2 * t4 + 1) + 1):
lbv = 2 * t2
ubv = min(m_size - 1, 2 * t2 + 1)
for t7 in range(2 * t2, min(m_size - 1, 2 * t2 + 1) + 1):
c[t7 - 2 * t2][t5 - 2 * t3] = S2_no_task(c[t7 - 2 * t2][t5 - 2 * t3], alpha, a[t7 - 2 * t2][t6 - 2 *
t4], b[t6 - 2 * t4][t5 - 2 * t3])


@task(var2=IN, beta=IN, returns=1)
def S1(var2, beta):
return scale(var2, beta)


def S1_no_task(var2, beta):
return scale(var2, beta)


@task(var2=IN, alpha=IN, var3=IN, var4=IN, returns=1)
def S2(var2, alpha, var3, var4):
return multiply(var2, alpha, var3, var4)


def S2_no_task(var2, alpha, var3, var4):
return multiply(var2, alpha, var3, var4)


def matmul(a, b, c, m_size, alpha, beta, debug):
if debug:
print 'Matrix A:'
print a
print 'Matrix B:'
print b
print 'Matrix C:'
print c
if m_size >= 1:
lbp = 0
ubp = int(math.floor(float(m_size - 1) / float(2)))
for t2 in range(lbp, ubp + 1):
lbp = 0
ubp = int(math.floor(float(m_size - 1) / float(2)))
for t3 in range(0, int(math.floor(float(m_size - 1) / float(2))) + 1):
lbp = 2 * t3
ubp = min(m_size - 1, 2 * t3 + 1)
LT3_aux_0 = [[c[gv0][gv1] for gv1 in range(2 * t3, m_size if m_size >= 3 + 2 * t2 and -1 + m_size <=
2 * t3 <= m_size else 2 + 2 * t3 if m_size >= 3 + 2 * t2 and 2 * t3 <= -2 + m_size else m_size if
2 * t2 <= m_size <= 2 + 2 * t2 and -1 + m_size <= 2 * t3 <= m_size else 2 + 2 * t3, 1)] for gv0 in
range(2 * t2, 2 + 2 * t2 if m_size >= 3 + 2 * t2 and -1 + m_size <= 2 * t3 <= m_size else 2 + 2 *
t2 if m_size >= 3 + 2 * t2 and 2 * t3 <= -2 + m_size else m_size if 2 * t2 <= m_size <= 2 + 2 *
t2 and -1 + m_size <= 2 * t3 <= m_size else m_size, 1)]
LT3(t3, m_size, t2, beta, LT3_aux_0)
lbp = 0
ubp = int(math.floor(float(m_size - 1) / float(2)))
for t2 in range(lbp, ubp + 1):
lbp = 0
ubp = int(math.floor(float(m_size - 1) / float(2)))
for t3 in range(0, int(math.floor(float(m_size - 1) / float(2))) + 1):
lbp = 0
ubp = int(math.floor(float(m_size - 1) / float(2)))
for t4 in range(0, int(math.floor(float(m_size - 1) / float(2))) + 1):
lbp = 2 * t3
ubp = min(m_size - 1, 2 * t3 + 1)
LT4_aux_0 = [[a[gv0][gv1] for gv1 in range(2 * t4, 2 + 2 * t4 if 2 * t3 <= m_size <= 2 + 2 * t3 and
2 * t4 <= -2 + m_size and -1 + m_size <= 2 * t2 <= m_size else 2 + 2 * t4 if 2 * t3 <=
m_size <= 2 + 2 * t3 and 2 * t4 <= -2 + m_size and 2 * t2 <= -2 + m_size else m_size if 2 *
t3 <= m_size <= 2 + 2 * t3 and -1 + m_size <= 2 * t4 <= m_size and -1 + m_size <= 2 * t2 <=
m_size else m_size if 2 * t3 <= m_size <= 2 + 2 * t3 and -1 + m_size <= 2 * t4 <= m_size and
2 * t2 <= -2 + m_size else 2 + 2 * t4 if m_size >= 3 + 2 * t3 and 2 * t4 <= -2 + m_size and
-1 + m_size <= 2 * t2 <= m_size else 2 + 2 * t4 if m_size >= 3 + 2 * t3 and 2 * t4 <= -2 +
m_size and 2 * t2 <= -2 + m_size else m_size if m_size >= 3 + 2 * t3 and -1 + m_size <= 2 *
t4 <= m_size and -1 + m_size <= 2 * t2 <= m_size else m_size, 1)] for gv0 in range(2 * t2,
m_size if 2 * t3 <= m_size <= 2 + 2 * t3 and 2 * t4 <= -2 + m_size and -1 + m_size <= 2 * t2 <=
m_size else 2 + 2 * t2 if 2 * t3 <= m_size <= 2 + 2 * t3 and 2 * t4 <= -2 + m_size and 2 *
t2 <= -2 + m_size else m_size if 2 * t3 <= m_size <= 2 + 2 * t3 and -1 + m_size <= 2 * t4 <=
m_size and -1 + m_size <= 2 * t2 <= m_size else 2 + 2 * t2 if 2 * t3 <= m_size <= 2 + 2 * t3 and
-1 + m_size <= 2 * t4 <= m_size and 2 * t2 <= -2 + m_size else m_size if m_size >= 3 + 2 *
t3 and 2 * t4 <= -2 + m_size and -1 + m_size <= 2 * t2 <= m_size else 2 + 2 * t2 if m_size >=
3 + 2 * t3 and 2 * t4 <= -2 + m_size and 2 * t2 <= -2 + m_size else m_size if m_size >= 3 +
2 * t3 and -1 + m_size <= 2 * t4 <= m_size and -1 + m_size <= 2 * t2 <= m_size else 2 + 2 *
t2, 1)]
LT4_aux_1 = [[b[gv0][gv1] for gv1 in range(2 * t3, m_size if 2 * t3 <= m_size <= 2 + 2 * t3 and
2 * t4 <= -2 + m_size and -1 + m_size <= 2 * t2 <= m_size else m_size if 2 * t3 <= m_size <=
2 + 2 * t3 and 2 * t4 <= -2 + m_size and 2 * t2 <= -2 + m_size else m_size if 2 * t3 <=
m_size <= 2 + 2 * t3 and -1 + m_size <= 2 * t4 <= m_size and -1 + m_size <= 2 * t2 <= m_size
else m_size if 2 * t3 <= m_size <= 2 + 2 * t3 and -1 + m_size <= 2 * t4 <= m_size and 2 *
t2 <= -2 + m_size else 2 + 2 * t3 if m_size >= 3 + 2 * t3 and 2 * t4 <= -2 + m_size and -1 +
m_size <= 2 * t2 <= m_size else 2 + 2 * t3 if m_size >= 3 + 2 * t3 and 2 * t4 <= -2 + m_size and
2 * t2 <= -2 + m_size else 2 + 2 * t3 if m_size >= 3 + 2 * t3 and -1 + m_size <= 2 * t4 <=
m_size and -1 + m_size <= 2 * t2 <= m_size else 2 + 2 * t3, 1)] for gv0 in range(2 * t4, 2 +
2 * t4 if 2 * t3 <= m_size <= 2 + 2 * t3 and 2 * t4 <= -2 + m_size and -1 + m_size <= 2 * t2 <=
m_size else 2 + 2 * t4 if 2 * t3 <= m_size <= 2 + 2 * t3 and 2 * t4 <= -2 + m_size and 2 *
t2 <= -2 + m_size else m_size if 2 * t3 <= m_size <= 2 + 2 * t3 and -1 + m_size <= 2 * t4 <=
m_size and -1 + m_size <= 2 * t2 <= m_size else m_size if 2 * t3 <= m_size <= 2 + 2 * t3 and
-1 + m_size <= 2 * t4 <= m_size and 2 * t2 <= -2 + m_size else 2 + 2 * t4 if m_size >= 3 + 2 *
t3 and 2 * t4 <= -2 + m_size and -1 + m_size <= 2 * t2 <= m_size else 2 + 2 * t4 if m_size >=
3 + 2 * t3 and 2 * t4 <= -2 + m_size and 2 * t2 <= -2 + m_size else m_size if m_size >= 3 +
2 * t3 and -1 + m_size <= 2 * t4 <= m_size and -1 + m_size <= 2 * t2 <= m_size else m_size, 1)]
LT4_aux_2 = [[c[gv0][gv1] for gv1 in range(2 * t3, 2 + 2 * t3 if m_size >= 3 + 2 * t3 and -1 +
m_size <= 2 * t4 <= m_size and -1 + m_size <= 2 * t2 <= m_size else 2 + 2 * t3 if m_size >=
3 + 2 * t3 and 2 * t4 <= -2 + m_size and -1 + m_size <= 2 * t2 <= m_size else m_size if 2 *
t3 <= m_size <= 2 + 2 * t3 and -1 + m_size <= 2 * t4 <= m_size and -1 + m_size <= 2 * t2 <=
m_size else m_size if 2 * t3 <= m_size <= 2 + 2 * t3 and 2 * t4 <= -2 + m_size and -1 +
m_size <= 2 * t2 <= m_size else 2 + 2 * t3 if m_size >= 3 + 2 * t3 and -1 + m_size <= 2 * t4 <=
m_size and 2 * t2 <= -2 + m_size else 2 + 2 * t3 if m_size >= 3 + 2 * t3 and 2 * t4 <= -2 +
m_size and 2 * t2 <= -2 + m_size else m_size if 2 * t3 <= m_size <= 2 + 2 * t3 and -1 +
m_size <= 2 * t4 <= m_size and 2 * t2 <= -2 + m_size else m_size, 1)] for gv0 in range(2 *
t2, m_size if m_size >= 3 + 2 * t3 and -1 + m_size <= 2 * t4 <= m_size and -1 + m_size <= 2 *
t2 <= m_size else m_size if m_size >= 3 + 2 * t3 and 2 * t4 <= -2 + m_size and -1 + m_size <=
2 * t2 <= m_size else m_size if 2 * t3 <= m_size <= 2 + 2 * t3 and -1 + m_size <= 2 * t4 <=
m_size and -1 + m_size <= 2 * t2 <= m_size else m_size if 2 * t3 <= m_size <= 2 + 2 * t3 and
2 * t4 <= -2 + m_size and -1 + m_size <= 2 * t2 <= m_size else 2 + 2 * t2 if m_size >= 3 + 2 *
t3 and -1 + m_size <= 2 * t4 <= m_size and 2 * t2 <= -2 + m_size else 2 + 2 * t2 if m_size >=
3 + 2 * t3 and 2 * t4 <= -2 + m_size and 2 * t2 <= -2 + m_size else 2 + 2 * t2 if 2 * t3 <=
m_size <= 2 + 2 * t3 and -1 + m_size <= 2 * t4 <= m_size and 2 * t2 <= -2 + m_size else 2 +
2 * t2, 1)]
LT4(t3, m_size, t4, t2, alpha, LT4_aux_0, LT4_aux_1, LT4_aux_2)
compss_barrier()
if debug:
print 'Matrix C:'
print c
return c

# [COMPSs Autoparallel] End Autogenerated code
Original file line number Diff line number Diff line change
Expand Up @@ -650,15 +650,18 @@ def test_multiply_taskified(self):
# Check file content
expected_file1 = tests_path + "/test3_multiply_taskified.expected1.pycompss"
expected_file2 = tests_path + "/test3_multiply_taskified.expected2.pycompss"
expected_file3 = tests_path + "/test3_multiply_taskified.expected3.pycompss"
try:
with open(expected_file1, 'r') as f:
expected_content1 = f.read()
with open(expected_file2, 'r') as f:
expected_content2 = f.read()
with open(expected_file3, 'r') as f:
expected_content3 = f.read()
with open(out_file, 'r') as f:
out_content = f.read()

self.assertIn(out_content, [expected_content1, expected_content2])
self.assertIn(out_content, [expected_content1, expected_content2, expected_content3])
except Exception:
raise
finally:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def __str__(self):

class TestScop2PScop2Py(unittest.TestCase):

def test_matmul(self):
def _test_matmul(self):
import os
dir_path = os.path.dirname(os.path.realpath(__file__))

Expand Down Expand Up @@ -142,7 +142,7 @@ def test_matmul(self):
# Erase output file
TestScop2PScop2Py._clean(output_file)

def test_seidel(self):
def _test_seidel(self):
import os
dir_path = os.path.dirname(os.path.realpath(__file__))

Expand Down

0 comments on commit 3169c7f

Please sign in to comment.