Lancelot / src / gpudb / QueryProcessing.h
QueryProcessing.h
Raw
#ifndef _QUERY_PROCESSING_H_
#define _QUERY_PROCESSING_H_

#include "MultiGPUProcessing.h"
#include "common.h"

extern int queries[13];

class QueryProcessing {
public:
  CacheManager* cm;
  QueryOptimizer* qo;
  CPUGPUProcessing* cgp;
  QueryParams* params;
  int count_zipfian;

  cudaStream_t streams[MAX_GROUPS][NUM_GPU];

  // map<int, int> query_freq;
  int query;
  bool verbose;
  bool custom;
  bool skipping;
  bool adaptive;
  int latemat;
  bool* broadcast;
  bool* already_partitioned;
  ncclComm_t* comms;

  double logical_time;

  Distribution dist;

  QueryProcessing(CPUGPUProcessing* _cgp, bool _verbose, Distribution _dist, ncclComm_t* _comms, bool _adaptive, int _latemat) {
    cgp = _cgp;
    qo = cgp->qo;
    cm = cgp->cm;
    // query_freq[_query] = 0;
    verbose = _verbose;
    dist = _dist;
    custom = cgp->custom;
    skipping = cgp->skipping;
    adaptive = _adaptive;
    latemat = _latemat;
    logical_time = 0;
    broadcast = new bool[NUM_TABLE]();
    already_partitioned = new bool[NUM_TABLE]();
    comms = _comms;
    count_zipfian = 0;
  }

  ~QueryProcessing() {
    // query_freq.clear();
  }

  void generate_rand_query() {
    query = queries[rand() % NUM_QUERIES];
    cout << query << endl;
    // query_freq[query] = 0;
  }

  void setQuery(int _query) {
    query = _query;
  }

  void runQuery(CUcontext ctx = NULL);

  void endQuery();

  void updateStatsQuery();

  double processQuery(CUcontext ctx = NULL);

  // void profile();

  void percentageData();

  void dumpTrace(string filename);

  void countTouchedSegment(int table_id, int* t_segment, int* t_c_segment);

  void executeTableDim(int table_id, int sg);

  void executeTableFactSimplified(int sg);

  void ShuffleAwareExec();

  void PartitioningOnlyExec();

  void ReplicationOnlyExec();

};

#endif