Skip to content
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

Fixing Arithmetic / Memory Complexity #840

Draft
wants to merge 69 commits into
base: devel
Choose a base branch
from
Draft

Fixing Arithmetic / Memory Complexity #840

wants to merge 69 commits into from

Conversation

abkhaoula
Copy link
Contributor

Fixing the computation of Arithmetic , Memory and Intensity Complexity

@@ -50,11 +50,11 @@ def assemble_matrix_ex01(ne1: 'int', ne2: 'int',
v = 0.0
for g1 in range(0, k1):
for g2 in range(0, k2):
bi_0 = basis_1[ie1, il_1, 0, g1] * basis_2[ie2, il_2, 0, g2]
# bi_0 = basis_1[ie1, il_1, 0, g1] * basis_2[ie2, il_2, 0, g2]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this has changed your computational intensity results. Do you not need bi_0/bj_0? Do you think it makes sense to change the expected intensity or are these here for a reason? We could just return them to avoid them being seen as useless?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think as long as it is just a function we are using for testing purpose it would be better to delete them and edit the complexity value

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Then should we delete them rather than just commenting?

@EmilyBourne EmilyBourne marked this pull request as ready for review June 22, 2021 20:11
if self.mode:
return ops + 1
else:
return ops + Symbol('ARCTANH')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if these can be simplified now that #754 has been fixed? I.e by doing:

def _cost_NumpyUfuncBase(self, expr, **settings):
    ops = sum(self._cost(i, **settings) for i in expr.args)
    if self.mode:
        return ops + 1
    else:
        return ops + Symbol(expr.name.upper())

@@ -3,6 +3,11 @@
# This file is part of Pyccel which is released under MIT License. See the LICENSE file or #
# go to https://github.com/pyccel/pyccel/blob/master/LICENSE for full license details. #
#------------------------------------------------------------------------------------------#
# pylint: disable=R0201, missing-function-docstring

# TODO: - Pow
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_cost_PyccelPower is defined at line 234. Does it still need to be in the TODO?

Comment on lines +246 to +247
# TODO add other numpy array constructors
if isinstance(expr.rhs, (NumpyZeros, NumpyOnes)):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this TODO be handled by just doing if isinstance(expr.rhs, NumpyNewArray)?

return sum(count_ops(i, visual) for i in expr)
else:
raise NotImplementedError('TODO count_ops for {}'.format(type(expr)))
return ntimes * ( self._cost(expr.rhs, **settings) )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the multiplication is only done in _cost_Assign then the wrong cost will be calculated for standalone expressions. Has this case been considered?

Comment on lines +257 to +259
def _cost_AugAssign(self, expr, **settings):
# TODO add other numpy array constructors
if isinstance(expr.rhs, (NumpyZeros, NumpyOnes, Comment, EmptyNode)):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above can't you use NumpyNewArray?

Also why do you have Comment and EmptyNode? I don't think it is possible to do a += #None


print('----------------------')
i = 0
comp = [READ*n**3/2 + 3*READ*n**2/2 + READ + WRITE*n**3/6 + 3*WRITE*n**2/2 + WRITE*n/3 + WRITE,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above, function name please


print('----------------------')
i = 0
comp = [2*READ + WRITE*k1*k2 + WRITE*(p1 + 1)*(p2 + 1) + 2*WRITE + ne1*(READ + WRITE + ne2*(READ + WRITE*k1*k2 + WRITE + (p1 + 1)**2*(p2 + 1)**2*(14*READ + 6*WRITE + k1*k2*(18*READ + 7*WRITE)) + (p1 + 1)*(p2 + 1)*(READ*(p1 + 1)*(p2 + 1) + WRITE) + (p1 + 1)*(p2 + 1)*(READ + WRITE + k1*(READ + WRITE + k2*(5*READ + 2*WRITE)))))]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above, function name please. Also could you please break this line up so it fits on a screen please

Comment on lines +29 to +30
files = sorted(os.listdir(path_dir))
files = [os.path.join(path_dir,f) for f in files if (f.endswith(".py"))]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these used?

Comment on lines +46 to +47
files = sorted(os.listdir(path_dir))
files = [os.path.join(path_dir,f) for f in files if (f.endswith(".py"))]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these used?

Comment on lines +44 to +45
files = sorted(os.listdir(path_dir))
files = [os.path.join(path_dir,f) for f in files if (f.endswith(".py"))]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these used?

Comment on lines +211 to +213
end = ((e-b) / step)-1
# translate so that we always start from 0
return summation(ops, (i, 0, end))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Translating so that the index always starts from 0 leads to wrong results if loops inside loops depend on the index. E.g:

def test(degree : int):
    a = 0
    for j in range(1, degree+1):
        for r in range(j):
            a += 1
return a

@github-actions
Copy link

github-actions bot commented Apr 13, 2023

Ran tests on commit 5472e10, for more details see here

  • ❌ linux / Unit tests
  • ❌ macosx / Unit tests
  • ✔️ pylint / Python best practices
  • ❌ docs / Documentation Format
  • ✔️ lint / Best practices
  • ✔️ spelling / Documentation spellcheck
  • ❌ windows / Unit tests

@github-actions github-actions bot marked this pull request as draft April 13, 2023 11:43
@github-actions
Copy link

Unfortunately your PR is not passing the tests so it is not quite ready for review yet. Let me know when it is fixed with /bot mark as ready.

The failing tests are:

  • linux / Unit tests
  • windows / Unit tests
  • macosx / Unit tests
  • docs / Documentation Format

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants