Skip to content
This repository was archived by the owner on Jun 14, 2025. It is now read-only.

Conversation

@cmikida2
Copy link
Contributor

@cmikida2 cmikida2 commented May 11, 2021

This PR aims to add functionality for arrays of user types to dagrt's builtins, for the purposes of generating code for the instructions provided by Leap in this PR.

@cmikida2 cmikida2 mentioned this pull request May 11, 2021
3 tasks
Copy link
Owner

@inducer inducer left a comment

Choose a reason for hiding this comment

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

Thanks! I think this one will require some thought...

return np.vdot(a, b)


def builtin_cumulative_product(a, axis):
Copy link
Owner

Choose a reason for hiding this comment

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

Dagrt arrays don't have axes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was only being used in one place in BDF, and I managed to remove it (562b2b5)

Comment on lines 95 to 102
def builtin_array_utype(n, x):
import numpy as np
if n != np.floor(n):
raise ValueError("array() argument n is not an integer")
n = int(n)

return np.empty((n, x.size), dtype=x.dtype)
#return np.zeros((n, x.size), dtype=x.dtype)
Copy link
Owner

Choose a reason for hiding this comment

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

Could you explain the use case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This builtin is needed for when we need to index into a set of user types at runtime (i.e. we cannot create a set of distinct usertype variables at generation time). In the context of BDF/this PR, the use case is Nordsieck history arrays (see this paper, eq. 2.6), which in the context of variable order must (at least I think) be a single array of user types.

identifier = "<builtin>norm_2"


class NormWRMS(_NormBase):
Copy link
Owner

Choose a reason for hiding this comment

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

Can you add these to the docs? (i.e. make it so that they show up in the documentation) There's a list in the module docstring.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done by 562b2b5.

return np.vdot(a, b)


def builtin_cumulative_product(a, axis):
Copy link
Owner

Choose a reason for hiding this comment

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

Could you explain the use case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was only being used in one place in BDF, and I managed to remove it (562b2b5)

if check and not isinstance(x_kind, (NoneType, Array, UserType)):
raise TypeError("argument 'x' of 'array_utype' is not a user type")

return (Array(is_real_valued=True),)
Copy link
Owner

Choose a reason for hiding this comment

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

This isn't true, really. Particularly the is_real_valued part.


is_real_valued = a_kind.is_real_valued and b_kind.is_real_valued

return (Array(is_real_valued),)
Copy link
Owner

Choose a reason for hiding this comment

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

Also problematic.

Comment on lines 122 to 123
def builtin_reshape(a, a_cols):
return a.reshape(-1, a_cols, order="F")
Copy link
Owner

Choose a reason for hiding this comment

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

Since dagrt arrays don't have shapes other than "1D vector", "reshape" is an odd addition IMO.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was only being used in one place in BDF, and I managed to remove it (562b2b5)

@inducer inducer changed the title Adds builtins for BDF/NDF use in Leap Arrays of user types May 27, 2021
@inducer
Copy link
Owner

inducer commented Jun 11, 2021

Could you remind me of the status of this? Is it ready to review? (If not, please mark as draft.)

@cmikida2 cmikida2 marked this pull request as draft June 11, 2021 15:23
@cmikida2
Copy link
Contributor Author

It will be ready soon, but isn't quite ready (need to put in place the outside-the-loop alloc/dealloc we talked about yesterday)

@cmikida2
Copy link
Contributor Author

@inducer this is ready for review - I'm removing the draft status after fixing what I could of the memory movement within loops.

@cmikida2 cmikida2 marked this pull request as ready for review June 16, 2021 17:38
@cmikida2
Copy link
Contributor Author

@inducer I've just looked this over again and brought it up to speed with the main dagrt branch. It remains, as far as I can see, ready for a further look, or at the very least is in a good position for someone else to pick it up and make any further tweaks necessary.

If a refresher on motivation is needed, I would direct the reader to this paper, and in particular the use of Nordsieck history arrays for BDF integration as per this PR.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants