PandA-2024.02
lubm_trinityq4.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include "simple_API.h"
3 
4 // var_2 = "<http://www.Department0.University0.edu>"
5 // p_var_3 = "ub:worksFor"
6 // p_var_4 = "ub:FullProfessor"
7 // p_var_5 = "a"
8 // p_var_7 = "ub:name"
9 // p_var_9 = "ub:emailAddress"
10 // p_var_11 = "ub:telephone"
11 
12 __attribute__((noinline))
13 void kernel(size_t i_var_3, Graph * graph, NodeId var_2, PropertyId p_var_3, PropertyId p_var_4, PropertyId p_var_5, PropertyId p_var_7, PropertyId p_var_9, PropertyId p_var_11, size_t in_degree_var_2, Edge * var_2_1_inEdges)
14 {
15  unsigned localCounter = 0;
16  PropertyId var_3; //corresponding to element having label "ub:worksFor"
17  var_3 = var_2_1_inEdges[i_var_3].property;
18  NodeId var_1; //corresponding to element having label "?X"
19  var_1 = var_2_1_inEdges[i_var_3].node;
20  int cond_level_2 = (var_3 == p_var_3);
21  if(cond_level_2)
22  {
23  size_t out_degree_var_1 = getOutDegree(graph, var_1);
24  Edge * var_1_3_outEdges = getOutEdges(graph, var_1);
25  size_t i_var_5;
26  for(i_var_5=0; i_var_5 < out_degree_var_1; i_var_5++)
27  {
28  PropertyId var_5; //corresponding to element having label "a"
29  var_5 = var_1_3_outEdges[i_var_5].property;
30  NodeId var_4; //corresponding to element having label "ub:FullProfessor"
31  var_4 = var_1_3_outEdges[i_var_5].node;
32  int cond_level_4 = ((var_5 == p_var_5) & (var_4 == p_var_4));
33  if(cond_level_4)
34  {
35  Edge * var_1_5_outEdges = getOutEdges(graph, var_1);
36  size_t i_var_7;
37  for(i_var_7=0; i_var_7 < out_degree_var_1; i_var_7++)
38  {
39  PropertyId var_7; //corresponding to element having label "ub:name"
40  var_7 = var_1_5_outEdges[i_var_7].property;
41  NodeId var_6; //corresponding to element having label "?Y1"
42  var_6 = var_1_5_outEdges[i_var_7].node;
43  int cond_level_6 = (var_7 == p_var_7);
44  if(cond_level_6)
45  {
46  Edge * var_1_7_outEdges = getOutEdges(graph, var_1);
47  size_t i_var_9;
48  for(i_var_9=0; i_var_9 < out_degree_var_1; i_var_9++)
49  {
50  PropertyId var_9; //corresponding to element having label "ub:emailAddress"
51  var_9 = var_1_7_outEdges[i_var_9].property;
52  NodeId var_8; //corresponding to element having label "?Y2"
53  var_8 = var_1_7_outEdges[i_var_9].node;
54  int cond_level_8 = (var_9 == p_var_9);
55  if(cond_level_8)
56  {
57  Edge * var_1_9_outEdges = getOutEdges(graph, var_1);
58  size_t i_var_11;
59  for(i_var_11=0; i_var_11 < out_degree_var_1; i_var_11++)
60  {
61  PropertyId var_11; //corresponding to element having label "ub:telephone"
62  var_11 = var_1_9_outEdges[i_var_11].property;
63  NodeId var_10; //corresponding to element having label "?Y3"
64  var_10 = var_1_9_outEdges[i_var_11].node;
65  int cond_level_10 = (var_11 == p_var_11);
66  if(cond_level_10)
67  {
68  // here the "required" results are written (if any)
69  localCounter++;
70  }
71  }
72  }
73  }
74  }
75  }
76  }
77  }
78  atomicIncrement(&(counter[i_var_3 % N_THREADS]), localCounter);
79  }
80 }
81 
82 __attribute__((noinline))
83 void parallel(Graph * graph, NodeId var_2, PropertyId p_var_3, PropertyId p_var_4, PropertyId p_var_5, PropertyId p_var_7, PropertyId p_var_9, PropertyId p_var_11, size_t in_degree_var_2, Edge * var_2_1_inEdges)
84 {
85  size_t i_var_3;
86  #pragma omp parallel for
87  for(i_var_3=0; i_var_3 < in_degree_var_2; i_var_3++)
88  {
89  kernel(i_var_3, graph, var_2, p_var_3, p_var_4, p_var_5, p_var_7, p_var_9, p_var_11, in_degree_var_2, var_2_1_inEdges);
90  }
91 }
92 
93 __attribute__((noinline))
94 int search(Graph * graph, NodeId var_2, PropertyId p_var_3, PropertyId p_var_4, PropertyId p_var_5, PropertyId p_var_7, PropertyId p_var_9, PropertyId p_var_11)
95 {
96  size_t in_degree_var_2 = getInDegree(graph, var_2);
97  Edge * var_2_1_inEdges = getInEdges(graph, var_2);
98  printf("In degree %d\n", in_degree_var_2);
99  parallel(graph, var_2, p_var_3, p_var_4, p_var_5, p_var_7, p_var_9, p_var_11, in_degree_var_2, var_2_1_inEdges);
100  for (int i = 0; i < N_THREADS; ++i)
101  numAnswers += counter[i];
102  return numAnswers;
103 }
104 
105 
106 int test(NodeId var_2, PropertyId p_var_3, PropertyId p_var_4, PropertyId p_var_5, PropertyId p_var_7, PropertyId p_var_9, PropertyId p_var_11)
107 {
108 #if defined(DATASETInVertexFile) && defined(DATASETOutVertexFile) && defined(DATASETInEdgeFile) && defined(DATASETOutEdgeFile)
109  loadGraph(DATASETInVertexFile, DATASETOutVertexFile, DATASETInEdgeFile, DATASETOutEdgeFile);
110 #else
111  //loadGraph("dataset/40-InVertexFile.bin", "dataset/40-OutVertexFile.bin", "dataset/40-InEdgeFile.bin", "dataset/40-OutEdgeFile.bin");
112  loadGraph("dataset/1-InVertexFile.bin", "dataset/1-OutVertexFile.bin", "dataset/1-InEdgeFile.bin", "dataset/1-OutEdgeFile.bin");
113 #endif
114 
115 // var_2 = "<http://www.Department0.University0.edu>" 4804
116 // p_var_3 = "ub:worksFor" 16
117 // p_var_4 = "ub:FullProfessor" 21219
118 // p_var_5 = "a" 14
119 // p_var_7 = "ub:name" 17
120 // p_var_9 = "ub:emailAddress" 10
121 // p_var_11 = "ub:telephone" 11
122  int ret_value = search(&TheGraph, var_2, p_var_3, p_var_4, p_var_5, p_var_7, p_var_9, p_var_11);
123  printf("%d\n", ret_value);
124  return ret_value;
125 }
126 
127 
128 #ifdef DEBUG
129 int main() {
130  return test(8204, 2, 6764, 10, 8, 17, 16) != 10;
131  //return test(4804, 16, 21219, 14, 17, 10, 11);
132 }
133 #endif
PropertyId property
Definition: simple_API.h:18
int main()
unsigned int PropertyId
Definition: simple_API.h:13
unsigned int NodeId
Definition: simple_API.h:11
Graph TheGraph
Definition: data.c:7
static Edge * getInEdges(Graph *graph, NodeId node)
Definition: simple_API.h:50
NodeId node
Definition: simple_API.h:17
static size_t getInDegree(Graph *graph, NodeId node)
Definition: simple_API.h:45
static Edge * getOutEdges(Graph *graph, NodeId node)
Definition: simple_API.h:65
#define N_THREADS
Definition: simple_API.h:7
void kernel(unsigned vertex, unsigned *p_Qnext, unsigned *Qnext_N, unsigned *map)
Definition: bfs.c:44
General class used to describe a graph in PandA.
Definition: graph.hpp:771
static size_t getOutDegree(Graph *graph, NodeId node)
Definition: simple_API.h:60
__attribute__((noinline))
int test(NodeId var_2, PropertyId p_var_3, PropertyId p_var_4, PropertyId p_var_5, PropertyId p_var_7, PropertyId p_var_9, PropertyId p_var_11)
void loadGraph(char *InVertexFileName, char *OutVertexFileName, char *InEdgeFileName, char *OutEdgeFileName)
Definition: load_graph.c:10
unsigned counter[N_THREADS]
Definition: data.c:3
unsigned numAnswers
Definition: data.c:5

Generated on Mon Feb 12 2024 13:02:47 for PandA-2024.02 by doxygen 1.8.13