Skip to content

Support P2F and F2P Convertors with multiple field arguments. #9

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

Merged
merged 3 commits into from
Apr 4, 2024

Conversation

Quasorglow
Copy link
Contributor

Convertors can take in and convert multiple fields for both 1D and 2D arrays at once.

void convert_float_to_posit(std::vector<double> &input,
std::vector<unsigned long> &output) {
std::transform(input.cbegin(), input.cend(), output.begin(),
[](float v) -> unsigned long {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this float? In the function signature it's std::vector<double> &input

exit(2);
}
}

void split_strings(std::string input, char delimiter,
Copy link
Collaborator

Choose a reason for hiding this comment

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

A function split_strings should have the vector<std::string> as the return type. If you are going with reference, the non output arguments should be marked with const

int index;
char *cvalue = NULL;
while (1) {
static struct option long_options[] = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you really need this inside a while loop? This can be present as a global const variable as it will not change

int c;
int index;
char *cvalue = NULL;
while (1) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be while (c = getopt_long(argc, argv, "o:t:h", long_options, &option_index)), a while(1) does not indicate the intent

convert_path<64, 3>(json, field, dim, transformed);
break;
case 128:
convert_path<128, 4>(json, field, dim, transformed);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Note: This case will lose precision when 128bit posit is represented as double. We would maybe convert the posit<bits, es> into a string directly

1. change the function signature to return output
2. rename Input to Args
3. make Args immutable
4. comment 128 bit case
5. add print usage function
6. change while loop condition when parsing the arguments
7. make long options global static constant
@Mark1626 Mark1626 merged commit c37b243 into thoughtworks:calyx-lib Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants