Skip to content

Commit

Permalink
Data packing lab
Browse files Browse the repository at this point in the history
  • Loading branch information
ivankochin committed Dec 24, 2024
1 parent b9a4519 commit 4e9ef22
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions labs/memory_bound/data_packing/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ S create_entry(int first_value, int second_value) {
S entry;

entry.i = first_value;
entry.s = static_cast<short>(second_value);
entry.l = static_cast<long long>(first_value * second_value);
entry.d = static_cast<double>(first_value) / maxRandom;
entry.s = static_cast<uint8_t>(second_value);
entry.l = static_cast<uint16_t>(first_value * second_value);
entry.d = static_cast<float>(first_value) / maxRandom;
entry.b = first_value < second_value;

return entry;
Expand Down
10 changes: 5 additions & 5 deletions labs/memory_bound/data_packing/solution.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ constexpr int maxRandom = 100;

// FIXME: this data structure can be reduced in size
struct S {
int i;
long long l;
short s;
double d;
bool b;
float d;
uint16_t l;
uint8_t i;
uint8_t s : 7;
bool b : 1;

bool operator<(const S &s) const { return this->i < s.i; }
};
Expand Down

0 comments on commit 4e9ef22

Please sign in to comment.