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

Poor random numbers in uint tests. #688

Closed
jsallay opened this issue Oct 28, 2023 · 1 comment · Fixed by #677
Closed

Poor random numbers in uint tests. #688

jsallay opened this issue Oct 28, 2023 · 1 comment · Fixed by #677
Labels

Comments

@jsallay
Copy link
Contributor

jsallay commented Oct 28, 2023

https://github.com/gnuradio/volk/blob/main/lib/qa_utils.cc#L54 Contains: float int_max = float(uint64_t(2) << (type.size * 8));. If type.size is 8, then int_max = uint64_t(2) << 64. Shift a 64-bit number by 64 is undefined behavior. It appears that gcc masks the shift amount and no shift is performed. Thus the random numbers generated are between 0 and 2 for unsigned 64-bit numbers and -1 and 1 for signed 64-bit numbers.

This is not ideal and causes some tests to not actually exercise algorithm. See #605

@jdemel
Copy link
Contributor

jdemel commented Nov 4, 2023

This line is part of:

void load_random_data(void* data, volk_type_t type, unsigned int n)

My idea to fix this issue would be:

  1. Implement another function for every type
  2. Add an optional seed for reproducible results
  3. Call the specialized functions from load_random_data

The structure is created here:

volk_type_t volk_type_from_string(std::string name)

And this is

volk/lib/qa_utils.h

Lines 25 to 32 in e853e9b

struct volk_type_t {
bool is_float;
bool is_scalar;
bool is_signed;
bool is_complex;
int size;
std::string str;
};

Some templating may reduce the number of specific functions.

This issue is related to #326 .

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