You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
862 B

  1. /*
  2. * This is component of StoRM - Cuda Plugin to check whether a pair of uint_fast64_t and float gets auto-aligned to match 64bit boundaries
  3. */
  4. #include <cstdint>
  5. #include <utility>
  6. #include <vector>
  7. #define CONTAINER_SIZE 100ul
  8. int main(int argc, char* argv[]) {
  9. int result = 0;
  10. std::vector<std::pair<uint_fast64_t, float>> myVector;
  11. for (size_t i = 0; i < CONTAINER_SIZE; ++i) {
  12. myVector.push_back(std::make_pair(i, 42.12345f * i));
  13. }
  14. char* firstUintPointer = reinterpret_cast<char*>(&(myVector.at(0).first));
  15. char* secondUintPointer = reinterpret_cast<char*>(&(myVector.at(1).first));
  16. ptrdiff_t uintDiff = secondUintPointer - firstUintPointer;
  17. if (uintDiff == (2 * sizeof(uint_fast64_t))) {
  18. result = 2;
  19. } else if (uintDiff == (sizeof(uint_fast64_t) + sizeof(float))) {
  20. result = 3;
  21. } else {
  22. result = -5;
  23. }
  24. return result;
  25. }