OmniSciDB  04ee39c94c
BumpAllocatorTest.cpp File Reference
#include "TestHelpers.h"
#include <Catalog/Catalog.h>
#include <CudaMgr/CudaMgr.h>
#include <QueryEngine/ResultSet.h>
#include <QueryRunner/QueryRunner.h>
#include <gtest/gtest.h>
+ Include dependency graph for BumpAllocatorTest.cpp:

Go to the source code of this file.

Classes

struct  anonymous_namespace{BumpAllocatorTest.cpp}::GpuInfo
 
class  LowGpuBufferMemory
 
class  LowGpuBufferMemoryCpuRetry
 
class  MediumGpuBufferMemory
 

Namespaces

 anonymous_namespace{BumpAllocatorTest.cpp}
 

Macros

#define BASE_PATH   "./tmp"
 
#define SKIP_NO_GPU()
 

Typedefs

using QR = QueryRunner::QueryRunner
 

Functions

bool anonymous_namespace{BumpAllocatorTest.cpp}::skip_tests (const ExecutorDeviceType device_type)
 
std::shared_ptr< ResultSetanonymous_namespace{BumpAllocatorTest.cpp}::run_multiple_agg (const std::string &query_str, const ExecutorDeviceType device_type)
 
GpuInfo anonymous_namespace{BumpAllocatorTest.cpp}::get_gpu_info ()
 
bool anonymous_namespace{BumpAllocatorTest.cpp}::setup ()
 
 TEST_F (LowGpuBufferMemory, CPUMode)
 
 TEST_F (LowGpuBufferMemory, OutOfMemory)
 
 TEST_F (LowGpuBufferMemoryCpuRetry, OOMRetryOnCPU)
 
 TEST_F (MediumGpuBufferMemory, OutOfSlots)
 
int main (int argc, char **argv)
 

Variables

bool g_allow_cpu_retry
 
size_t g_max_memory_allocation_size
 
size_t g_min_memory_allocation_size
 
bool g_enable_bump_allocator
 
size_t anonymous_namespace{BumpAllocatorTest.cpp}::g_num_gpus {0}
 
bool anonymous_namespace{BumpAllocatorTest.cpp}::g_keep_data {false}
 
constexpr size_t row_count_per_gpu = 64
 

Macro Definition Documentation

◆ BASE_PATH

#define BASE_PATH   "./tmp"

◆ SKIP_NO_GPU

#define SKIP_NO_GPU ( )
Value:
LOG(WARNING) << "GPU not available, skipping GPU tests"; \
}
bool skip_tests(const ExecutorDeviceType device_type)

Definition at line 50 of file BumpAllocatorTest.cpp.

Referenced by TEST_F().

Typedef Documentation

◆ QR

Definition at line 30 of file BumpAllocatorTest.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 263 of file BumpAllocatorTest.cpp.

References logger::ERROR, g_enable_bump_allocator, anonymous_namespace{BumpAllocatorTest.cpp}::g_keep_data, logger::LogOptions::get_options(), logger::init(), LOG, logger::LogOptions::max_files_, QueryRunner::QueryRunner::reset(), run, and anonymous_namespace{BumpAllocatorTest.cpp}::setup().

263  {
264  testing::InitGoogleTest(&argc, argv);
265 
266  namespace po = boost::program_options;
267 
268  po::options_description desc("Options");
269 
270  // these two are here to allow passing correctly google testing parameters
271  desc.add_options()("gtest_list_tests", "list all tests");
272  desc.add_options()("gtest_filter", "filters tests, use --help for details");
273  desc.add_options()("keep-data",
274  "Don't drop tables at the end of the tests. Note that individual "
275  "tests may still create and drop tables. Use in combination with "
276  "--gtest_filter to preserve tables for a specific test group.");
277  desc.add_options()(
278  "test-help",
279  "Print all BumpAllocatorTest specific options (for gtest options use `--help`).");
280 
281  logger::LogOptions log_options(argv[0]);
282  log_options.max_files_ = 0; // stderr only by default
283  desc.add(log_options.get_options());
284 
285  po::variables_map vm;
286  po::store(po::command_line_parser(argc, argv).options(desc).run(), vm);
287  po::notify(vm);
288 
289  if (vm.count("test-help")) {
290  std::cout << "Usage: BumpAllocatorTest" << std::endl << std::endl;
291  std::cout << desc << std::endl;
292  return 0;
293  }
294 
295  if (vm.count("keep-data")) {
296  g_keep_data = true;
297  }
298 
299  logger::init(log_options);
300 
302 
303  if (!setup()) {
304  // No GPUs detected, bypass the test
305  return 0;
306  }
307 
308  int err{0};
309  try {
310  err = RUN_ALL_TESTS();
311  } catch (const std::exception& e) {
312  LOG(ERROR) << e.what();
313  }
314  QR::reset();
315  return err;
316 }
#define LOG(tag)
Definition: Logger.h:182
void init(LogOptions const &log_opts)
Definition: Logger.cpp:260
bool g_enable_bump_allocator
Definition: Execute.cpp:96
static bool run
+ Here is the call graph for this function:

◆ TEST_F() [1/4]

TEST_F ( LowGpuBufferMemory  ,
CPUMode   
)

Definition at line 135 of file BumpAllocatorTest.cpp.

References CPU, anonymous_namespace{BumpAllocatorTest.cpp}::g_num_gpus, and run_multiple_agg().

135  {
136  // Baseline correctness
137  auto result_rows =
138  run_multiple_agg("SELECT x FROM test WHERE x < 500;", ExecutorDeviceType::CPU);
139  ASSERT_EQ(result_rows->rowCount(), size_t(64 * g_num_gpus));
140 }
TQueryResult run_multiple_agg(std::string sql)
+ Here is the call graph for this function:

◆ TEST_F() [2/4]

TEST_F ( LowGpuBufferMemory  ,
OutOfMemory   
)

Definition at line 142 of file BumpAllocatorTest.cpp.

References GPU, run_multiple_agg(), and SKIP_NO_GPU.

142  {
143  SKIP_NO_GPU();
144 
145  try {
146  run_multiple_agg("SELECT x FROM test WHERE x < 500;", ExecutorDeviceType::GPU);
147  ASSERT_TRUE(false) << "Expected query to throw exception";
148  } catch (const std::exception& e) {
149  ASSERT_EQ(
150  std::string{"Query ran out of GPU memory, unable to automatically retry on CPU"},
151  std::string(e.what()));
152  }
153 }
#define SKIP_NO_GPU()
TQueryResult run_multiple_agg(std::string sql)
+ Here is the call graph for this function:

◆ TEST_F() [3/4]

TEST_F ( LowGpuBufferMemoryCpuRetry  ,
OOMRetryOnCPU   
)

Definition at line 198 of file BumpAllocatorTest.cpp.

References anonymous_namespace{BumpAllocatorTest.cpp}::g_num_gpus, GPU, row_count_per_gpu, run_multiple_agg(), and SKIP_NO_GPU.

198  {
199  SKIP_NO_GPU();
200 
201  try {
202  auto result_rows =
203  run_multiple_agg("SELECT x FROM test WHERE x < 500;", ExecutorDeviceType::GPU);
204  ASSERT_EQ(result_rows->rowCount(), size_t(row_count_per_gpu * g_num_gpus));
205  } catch (const std::exception& e) {
206  ASSERT_TRUE(false) << "Expected query to not throw exception. Query threw: "
207  << e.what();
208  }
209 }
constexpr size_t row_count_per_gpu
#define SKIP_NO_GPU()
TQueryResult run_multiple_agg(std::string sql)
+ Here is the call graph for this function:

◆ TEST_F() [4/4]

TEST_F ( MediumGpuBufferMemory  ,
OutOfSlots   
)

Definition at line 251 of file BumpAllocatorTest.cpp.

References GPU, run_multiple_agg(), and SKIP_NO_GPU.

251  {
252  SKIP_NO_GPU();
253 
254  try {
255  run_multiple_agg("SELECT x FROM test WHERE x < 5000;", ExecutorDeviceType::GPU);
256  ASSERT_TRUE(false) << "Expected query to throw exception";
257  } catch (const std::exception& e) {
258  ASSERT_EQ(std::string(e.what()),
259  std::string{"Ran out of slots in the query output buffer"});
260  }
261 }
#define SKIP_NO_GPU()
TQueryResult run_multiple_agg(std::string sql)
+ Here is the call graph for this function:

Variable Documentation

◆ g_allow_cpu_retry

◆ g_enable_bump_allocator

bool g_enable_bump_allocator

Definition at line 96 of file Execute.cpp.

Referenced by main().

◆ g_max_memory_allocation_size

size_t g_max_memory_allocation_size

Definition at line 92 of file Execute.cpp.

Referenced by MediumGpuBufferMemory::SetUp(), and MediumGpuBufferMemory::TearDown().

◆ g_min_memory_allocation_size

◆ row_count_per_gpu

constexpr size_t row_count_per_gpu = 64

Definition at line 155 of file BumpAllocatorTest.cpp.

Referenced by LowGpuBufferMemoryCpuRetry::SetUp(), and TEST_F().