-
Notifications
You must be signed in to change notification settings - Fork 10
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
Conversation
test_generator/F2PConvertor.cpp
Outdated
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 { |
There was a problem hiding this comment.
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
test_generator/F2PConvertor.cpp
Outdated
exit(2); | ||
} | ||
} | ||
|
||
void split_strings(std::string input, char delimiter, |
There was a problem hiding this comment.
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
test_generator/F2PConvertor.cpp
Outdated
int index; | ||
char *cvalue = NULL; | ||
while (1) { | ||
static struct option long_options[] = { |
There was a problem hiding this comment.
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
test_generator/F2PConvertor.cpp
Outdated
int c; | ||
int index; | ||
char *cvalue = NULL; | ||
while (1) { |
There was a problem hiding this comment.
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
test_generator/P2FConvertor.cpp
Outdated
convert_path<64, 3>(json, field, dim, transformed); | ||
break; | ||
case 128: | ||
convert_path<128, 4>(json, field, dim, transformed); |
There was a problem hiding this comment.
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
Convertors can take in and convert multiple fields for both 1D and 2D arrays at once.