Code Monkey home page Code Monkey logo

lara-framework's Introduction

lara-framework

Tools and APIs to develop weavers for the LARA language (LARA Compiler, LARA Interpreter, Weaver Generator, etc...)

The LARA framework is on Maven Repository.

configuring eclipse

Please check the README file in repository specs-java-libs.

acknowledgments

This work has been partially funded by the ANTAREX project through the EU H2020 FET-HPC program under grant no. 671623.

lara-framework's People

Contributors

cc187 avatar fabiodrg avatar gilteixeira avatar hugomfandrade avatar joaobispo avatar joaonmatos avatar juleshervault avatar lm-sousa avatar milenaaluisa avatar nasgregorio avatar pfsi avatar saltgilteixeira avatar tiagodrcarvalho avatar tiagodusilva avatar tiagolascasas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lara-framework's Issues

Clava's integration with Vitis HLS

Similar to our CMake integration, it would be nice if we could also have something similar for Vitis HLS.

This would work with a simple workflow: after we perform our HLS-related code transformations and directive insertion, we could synthesize the code with Vitis HLS, and parse the synthesis report into a JS-friendly format (i.e., JSON).

This would allow us to automatically estimate the performance of our transformed code using HLS, enabling processes like full Design Space Exploration in the near future.

Possible API usage

// after code transformations
const vitis = new VitisHLS();

vitis.addSource("foo.c");
vitis.setTopFunction("matrix_multiply");
vitis.setPlatform("xcvu5p-flva2104-1-e");
vitis.setClock(10);

var success = vitis.synthesize();
if (success) {
    var report = vitis.parseReport();
    println("Design latency: " + report["latency"]);
}

How to implement it

I think there is some intersectionality with the CMake extension, particularly when it comes to managing input files with the CMakerSources class. One idea could be to extract common functionality to a parent abstract class, and then to have extended classes for both CMake and Vitis HLS.

The integration with Vitis HLS itself is easy, as Vitis HLS works well as a command-line application and I already have the required scripts/commands to implement the entire flow, from creating a Vitis project to generating the synthesis report.

Folds in text editor do not work in main aspect/lara file

I noticed a consistent behaviour where folding works just fine in .lara files, except for the main lara file. Lets say my current lara file is Main.lara. As is, folds do not work. If I change my main lara to another file, folds in Main.lara work again! Therefore, I suspect the CurlyFoldParser is working as intended, but some settings are applied on the main Lara tab (treated especially) that are not applied on the other tabs? Or vice-versa?

Choose documentation format/WebUI

Currently we are using a custom HTML generator that receives as input the populated documentation model. However, we could output instead to some markdown and use a website generator. Options include Jekyll (used by GitHub pages), ReadTheDocs, DocPress, etc .

Exception when passing arguments with -av and aspect does not have input arguments

When calling a LARA aspect by command-line with input arguments (e.g., -av {arg1:10}) and the main aspect does not have inputs, the following exception occurs:

Exception in thread "main" java.lang.RuntimeException:
During LARA Interpreter execution
caused by RuntimeException:
when evaluating javascript
caused by ScriptException: TypeError: Cannot get property "length" of null in at line number 23
caused by ECMAException: TypeError: Cannot get property "length" of null
at jdk.nashorn.internal.runtime.ECMAErrors.error(ECMAErrors.java:57)

Add support for super class

Documentation model does not store information about super classes of classes.

  • For JS code that information is in the AST;
  • For LARA code that information would have to be extracted (but not might be needed if .lara is transformed into .js in the future);
  • There should be a link between the super and the destination class, if it exists in the documentation model. This could be a post-processing step;

Hardcoded replicated information regarding LaraJoinPoint

All these code snippets show the same information replicated across the codebase.
These should be consolidated into a single source of truth.

LaraJoinPointSpecification.add(Attribute.getActionsAttribute());
LaraJoinPointSpecification.add(Attribute.getAttributesAttribute());
LaraJoinPointSpecification.add(Attribute.getSelectsAttribute());
// JoinPointSpecification.add(new Attribute(null, "srcCode"));
LaraJoinPointSpecification.add(new Attribute(PrimitiveClasses.STRING, "dump"));
LaraJoinPointSpecification.add(new Attribute(PrimitiveClasses.STRING, "joinPointType"));
LaraJoinPointSpecification.add(new Attribute(PrimitiveClasses.OBJECT, "node"));
LaraJoinPointSpecification.add(new Attribute(new JPType(LaraJoinPointSpecification), "self"));
LaraJoinPointSpecification.add(new Attribute(new JPType(LaraJoinPointSpecification), "super"));
LaraJoinPointSpecification.add(new Attribute(new ArrayType(new JPType(LaraJoinPointSpecification)), "children"));
LaraJoinPointSpecification.add(new Attribute(new ArrayType(new JPType(LaraJoinPointSpecification)), "descendants"));
LaraJoinPointSpecification.add(new Attribute(new ArrayType(new JPType(LaraJoinPointSpecification)), "scopeNodes"));
LaraJoinPointSpecification.add(new Action(new JPType(LaraJoinPointSpecification), "insert", Arrays.asList(
new Parameter(new LiteralEnum("Position", Arrays.asList("before", "after", "replace")), "position"),
new Parameter(PrimitiveClasses.STRING, "code"))));
LaraJoinPointSpecification.add(new Action(new JPType(LaraJoinPointSpecification), "insert", Arrays.asList(
new Parameter(new LiteralEnum("Position", Arrays.asList("before", "after", "replace")), "position"),
new Parameter(new JPType(LaraJoinPointSpecification), "joinpoint"))));
LaraJoinPointSpecification.add(new Action(PrimitiveClasses.VOID, "def", Arrays.asList(
new Parameter(PrimitiveClasses.STRING, "attribute"),
new Parameter(PrimitiveClasses.OBJECT, "value"))));
LaraJoinPointSpecification.add(new Action(PrimitiveClasses.STRING, "toString"));
LaraJoinPointSpecification.add(new Action(PrimitiveClasses.BOOLEAN, "equals", Arrays.asList(
new Parameter(new JPType(LaraJoinPointSpecification), "jp"))));
LaraJoinPointSpecification.add(new Action(PrimitiveClasses.BOOLEAN, "instanceOf", Arrays.asList(
new Parameter(PrimitiveClasses.STRING, "name"))));

public Map<String, ActionArgument> createInsertParameters() {
final Map<String, ActionArgument> args = new LinkedHashMap<>();
final ActionArgument when = new ActionArgument(POSITION_ARGUMENT_NAME, "string", this);
args.put(POSITION_ARGUMENT_NAME, when);
final ActionArgument code = new ActionArgument(CODE_ARGUMENT_NAME, "template", this);
args.put(CODE_ARGUMENT_NAME, code);
return args;
}
public Map<String, ActionArgument> createDefParameters() {
final Map<String, ActionArgument> args = new LinkedHashMap<>();
final ActionArgument attribute = new ActionArgument(ATTRIBUTE_ARGUMENT_NAME, "string", this);
args.put(ATTRIBUTE_ARGUMENT_NAME, attribute);
final ActionArgument value = new ActionArgument(VALUE_ARGUMENT_NAME, "Object", this);
args.put(VALUE_ARGUMENT_NAME, value);
return args;
}

// Add default insert action
final Action insertAct = new Action();
insertAct.setName("insert");
insertAct.setClazz("*");
// action 'insert' returns an array of join points
insertAct.setReturn("Joinpoint[]");
final Parameter positionParam = new Parameter();
positionParam.setName("position");
positionParam.setType("String");
insertAct.getParameter().add(positionParam);
final Parameter codeParam = new Parameter();
codeParam.setName("code");
codeParam.setType("String");
insertAct.getParameter().add(codeParam);
actions.add(insertAct);
// Add default insert action overload that receives a JoinPoint
final Action insertActJp = new Action();
insertActJp.setName("insert");
insertActJp.setClazz("*");
// action 'insert' returns an array of join points
insertActJp.setReturn("Joinpoint[]");
final Parameter positionParam2 = new Parameter();
positionParam2.setName("position");
positionParam2.setType("String");
insertActJp.getParameter().add(positionParam2);
final Parameter codeParam2 = new Parameter();
codeParam2.setName("code");
codeParam2.setType("JoinpointInterface");
insertActJp.getParameter().add(codeParam2);
actions.add(insertActJp);
// Add default define (def) action
final Action defAct = new Action();
defAct.setName("def");
defAct.setClazz("*");
final Parameter attParam = new Parameter();
attParam.setName("attribute");
attParam.setType("String");
defAct.getParameter().add(attParam);
final Parameter valueParam = new Parameter();
valueParam.setName("value");
valueParam.setType("Object");
defAct.getParameter().add(valueParam);
actions.add(defAct);

INSERT = new Action(Primitive.VOID, "insert");
Action.INSERT.addParameter(new LiteralEnum("", "{before,after,replace}"), "position");
Action.INSERT.addParameter(PrimitiveClasses.STRING, "code");
DEF = new Action(Primitive.VOID, "def");
Action.DEF.addParameter(PrimitiveClasses.STRING, "attribute");
Action.DEF.addParameter(PrimitiveClasses.OBJECT, "value");

PrimitiveClasses string = PrimitiveClasses.STRING;
ArrayType stringA = new ArrayType(string);
ATTRIBUTES = new Attribute(stringA, "attributes");
SELECTS = new Attribute(stringA, "selects");
ACTIONS = new Attribute(stringA, "actions");

globalNode.add(Attribute.getAttributesAttribute());
globalNode.add(Attribute.getSelectsAttribute());
globalNode.add(Attribute.getActionsAttribute());
globalNode.add(Action.getInsertAction());
globalNode.add(Action.getDefAction());

https://github.com/specs-feup/lara-framework/blob/af1ab2e7b36777f19ae96bc1ef0bdf546e37b3d9/WeaverGenerator/src/org/lara/interpreter/weaver/generator/generator/java/helpers/SuperAbstractJoinPointGenerator.java

Improve HTML generation

There are some parts of HTML generation that should be improved:

  • Folders should have descriptive names, instead of numbers, to reduce changes when generating the documentation;

  • Should generate static HTML pages, instead of the current version that dynamically loads parts of the webpage using JS;

Use JavaCC21 to parse LARA

To obtain comments from LARA files, currently the files are being parsed using the legacy method, which converts LARA to AspectIR. Instead, use JavaCC21 parser and tree.

Will need to adapt the way comments are extracted and populated.

Add support for laraImport() in .mjs files

The function laraImport() is used to load .js files. Usually all variables declared in the loaded file become available in the scope they are loaded, but the only guarantee of the laraImport() function is that a variable with the same simple name of the import will become available in the global scope (e.g. import weaver.Query will make the name Query available globally).

Of course, for files to be compatible with being loaded with laraImport(), must be written in such a way so that they create a variable with the same name as the file.

.mjs files have different scoping rules, so when laraImport() loads the files, in some cases (e.g. JS classes) the declared variable does not become visible in the global scope. This breaks compatibility with code that uses laraImport().

Create API for LaraArgs

Currently arguments are passed from the weaver to the scripts through a global variable that is always present, laraArgs.

This should be re-implemented as an API that scripts that want to use must import, even if it continues to have global (read-only) state. This implies:

  • New API
  • Tests for laraArgs

Support for postorder traversal in Query.search()

By default, Query.search() performs a preorder traversal. However, sometimes postorder traversal is necessary.

Add support for specifying if we want a preorder or postorder traversal. Current proposal is to add an additional flag to Query.search() of an enum {preorder, postorder}, where preorder is the default value.

Support for system-wide default options

There is already a kind of support for default options, with the file local_options.xml, but it is limited to specific options defined for that file.

Implement a more generic mechanism which can accept common weaver configuration files.

GraalVM code for Java to JS conversion is mangling data for Node.js

When in the new Node.js environment, if we access a property of a joinpoint the return values may be mangled.

Let's take the rank property of Clava's CxxLoop joinpoint. The documentation says this property returns an array of numbers (number[]). This is true, to a point. The actual getter returns an Object type. A data type of GraalVM to represent javascript data-structures. This happens because the old implementation calls JsEngine.toNativeArray before returning to the javascript environment. In the new JsEngine implementation for the Node.js this toNativeArray method just returns the original object without modifications. However, in the end, due to the function type of the original getter, the array always gets cast to the Object datatype.

My suggestion in this case is to move the datatype conversion logic to the javascript environment just as we have been doing with all the other Java objects. I imagine this will require modifying the WeaverGenerator and/or the LanguageSpecification as even the Abstract joinpoint classes have this Object datatype as the getter return type.

Implement streaming in Joinpoint searches

          The idea of passing the function instead of a list was to allow, in the future, for the function to return an iterable, instead of forcing the creating of a list with all jps before the filtering.

Add a comment with this information, that for streaming to be implemented, we will need to change the input list to be for instance, an iterable/generator.

Right now, we should be very close for search() to work in a stream-like way, on the Java-side the base methods already return Streams.

Originally posted by @joaobispo in #63 (comment)

Mock "java" js module is only recognized at the second execution

When updating the Java resources in Lara Classic and the modules folder is updated, the "java" mock npm module is deleted and not recognized during execution. The second time the framework is executed, the "java" module is recognized and the application runs as intended.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.