Hybrid Query Processing Engine for Coprocessing in Database Systems
HyPE
unittest_c_interface.c
Go to the documentation of this file.
00001 
00002 
00003 #include <stdlib.h>
00004 #include <stdio.h>
00005 #include <stdint.h>
00006 
00007 #include <hype.h>
00008 
00009 
00010 int main(){
00011     /*#############################################################################*/
00012     /********************* Create Hardware Specification ***************************/
00013     /*#############################################################################*/
00014  C_AlgorithmSpecification* alg_spec_merge_sort = hype_createAlgorithmSpecification("MergeSort","SORT",Least_Squares_1D,Periodic,ResponseTime);
00015  C_AlgorithmSpecification* alg_spec_quick_sort = hype_createAlgorithmSpecification("QuickSort","SORT",Least_Squares_1D,Periodic,ResponseTime);
00016 
00017  C_DeviceSpecification* cpu_device = hype_createDeviceSpecification(PD0,CPU,PD_Memory_0);
00018  C_DeviceSpecification* gpu_device = hype_createDeviceSpecification(PD1,GPU,PD_Memory_1);
00019 
00020  if(!hype_addAlgorithm(alg_spec_merge_sort, cpu_device)) printf("Failed to add Algorithm Configuration");
00021  if(!hype_addAlgorithm(alg_spec_quick_sort, gpu_device)) printf("Failed to add Algorithm Configuration");
00022 
00023  hype_printStatus();
00024     /*#############################################################################*/
00025     /********************* Main Loop ***************************/
00026     /*#############################################################################*/
00027    unsigned int i;
00028    for(i=0;i<100;i++){
00029       printf("Iteration: %i\n",i);
00030     double buffer[1];
00031     buffer[0]=2.5;
00032 
00033    /*Build Query for HyPE*/
00034     C_OperatorSpecification* op_spec = hype_create_OperatorSpecification("SORT",buffer,1,PD_Memory_0,PD_Memory_0);
00035     C_DeviceConstraint* dev_constr = hype_createDeviceConstraint(ANY_DEVICE,PD_Memory_0);
00036    /*Query HyPE, on which processing device to use*/
00037     C_SchedulingDecision* sched_dec = hype_getOptimalAlgorithm(op_spec, dev_constr);
00038     
00039       //query scheduling decision
00040       uint64_t begin = hype_getTimestamp();
00041       //execute Algorithm
00042       uint64_t end = hype_getTimestamp();
00043 
00044      if(!hype_addObservation(sched_dec, (double)end-begin)) printf("Failed to add Observation");
00045      if(!hype_deleteSchedulingDecision(sched_dec)) printf("Failed to delete SchedulingDecision");
00046      if(!hype_deleteOperatorSpecification(op_spec)) printf("Failed to delete OperatorSpecification");
00047      if(!hype_deleteDeviceConstraint(dev_constr)) printf("Failed to delete device constraint");
00048    }
00049 
00050 
00051     /*#############################################################################*/
00052     /***************************** Free Ressources *********************************/
00053     /*#############################################################################*/
00054  if(!hype_deleteDeviceSpecification(cpu_device)) printf("Failed to free DeviceSpecification");
00055  if(!hype_deleteDeviceSpecification(gpu_device)) printf("Failed to free DeviceSpecification");
00056 
00057  if(!hype_deleteAlgorithmSpecification(alg_spec_merge_sort)) printf("Failed to free AlgortihmSpecification");
00058  if(!hype_deleteAlgorithmSpecification(alg_spec_quick_sort)) printf("Failed to free AlgortihmSpecification");
00059 
00060    return 0;
00061 }
00062 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines