summaryrefslogtreecommitdiff
path: root/test/correctness/misc/compile_invert.cpp
blob: 4ce458d11a4179a5dfe38dcffec980d1738d0f9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// =================================================================================================
// This file is part of the CLBlast project. The project is licensed under Apache Version 2.0. This
// project loosely follows the Google C++ styleguide and uses a tab-size of two spaces and a max-
// width of 100 characters per line.
//
// Author(s):
//   Cedric Nugteren <www.cedricnugteren.nl>
//
// This file contains a simple test to compile the invert kernel.
//
// =================================================================================================

#include <string>
#include <vector>
#include <cstdio>

#include "utilities/utilities.hpp"
#include "routines/levelx/xinvert.hpp"

namespace clblast {
// =================================================================================================

template <typename T>
size_t CompileInvertKernels(int argc, char *argv[], const bool silent) {

  // Retrieves the arguments
  auto help = std::string{"Options given/available:\n"};
  auto arguments = RetrieveCommandLineArguments(argc, argv);
  const auto platform_id = GetArgument(arguments, help, kArgPlatform, ConvertArgument(std::getenv("CLBLAST_PLATFORM"), size_t{0}));
  const auto device_id = GetArgument(arguments, help, kArgDevice, ConvertArgument(std::getenv("CLBLAST_DEVICE"), size_t{0}));

  // Prints the help message (command-line arguments)
  if (!silent) { fprintf(stdout, "\n* %s\n", help.c_str()); }

  // Initializes OpenCL
  const auto platform = Platform(platform_id);
  const auto device = Device(platform, device_id);
  const auto context = Context(device);
  auto queue = Queue(context, device);

  // Compiles the invert kernels
  auto diagonal_invert_event = Event();
  auto inverter = Xinvert<T>(queue, diagonal_invert_event.pointer());

  // Report and return
  printf("\n");
  printf("    1 test(s) passed\n");
  printf("    0 test(s) failed\n");
  printf("\n");
  return 0;
}

// =================================================================================================
} // namespace clblast

// Main function (not within the clblast namespace)
int main(int argc, char *argv[]) {
  auto errors = size_t{0};
  errors += clblast::CompileInvertKernels<float>(argc, argv, false);
  errors += clblast::CompileInvertKernels<clblast::float2>(argc, argv, true);
  if (errors > 0) { return 1; } else { return 0; }
}

// =================================================================================================