PandA-2024.02
lubm_trinityq3.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include "simple_API.h"
3 
4 // var_2 = "ub:UndergraduateStudent"
5 // p_var_3 = "a"
6 // p_var_5 = "ub:University"
7 // p_var_6 = "a"
8 // p_var_8 = "ub:Department"
9 // p_var_9 = "a"
10 // p_var_10 = "ub:memberOf"
11 // p_var_11 = "ub:subOrganizationOf"
12 // p_var_12 = "ub:undergraduateDegreeFrom"
13 
14 __attribute__((noinline))
15 void kernel(size_t i_var_3, Graph * graph, NodeId var_2, PropertyId p_var_3, PropertyId p_var_5, PropertyId p_var_6, PropertyId p_var_8, PropertyId p_var_9, PropertyId p_var_10, PropertyId p_var_11, PropertyId p_var_12, size_t in_degree_var_2, Edge * var_2_1_inEdges)
16 {
17  unsigned localCounter = 0;
18  PropertyId var_3; //corresponding to element having label "a"
19  var_3 = var_2_1_inEdges[i_var_3].property;
20  NodeId var_1; //corresponding to element having label "?X"
21  var_1 = var_2_1_inEdges[i_var_3].node;
22  int cond_level_2 = (var_3 == p_var_3);
23  if(cond_level_2)
24  {
25  size_t out_degree_var_1 = getOutDegree(graph, var_1);
26  Edge * var_1_3_outEdges = getOutEdges(graph, var_1);
27  size_t i_var_10;
28  for(i_var_10=0; i_var_10 < out_degree_var_1; i_var_10++)
29  {
30  PropertyId var_10; //corresponding to element having label "ub:memberOf"
31  var_10 = var_1_3_outEdges[i_var_10].property;
32  NodeId var_7; //corresponding to element having label "?Z"
33  var_7 = var_1_3_outEdges[i_var_10].node;
34  int cond_level_4 = (var_10 == p_var_10);
35  if(cond_level_4)
36  {
37  size_t out_degree_var_7 = getOutDegree(graph, var_7);
38  Edge * var_7_5_outEdges = getOutEdges(graph, var_7);
39  size_t i_var_9;
40  for(i_var_9=0; i_var_9 < out_degree_var_7; i_var_9++)
41  {
42  PropertyId var_9; //corresponding to element having label "a"
43  var_9 = var_7_5_outEdges[i_var_9].property;
44  NodeId var_8; //corresponding to element having label "ub:Department"
45  var_8 = var_7_5_outEdges[i_var_9].node;
46  int cond_level_6 = ((var_9 == p_var_9) & (var_8 == p_var_8));
47  if(cond_level_6)
48  {
49  Edge * var_1_7_outEdges = getOutEdges(graph, var_1);
50  size_t i_var_12;
51  for(i_var_12=0; i_var_12 < out_degree_var_1; i_var_12++)
52  {
53  PropertyId var_12; //corresponding to element having label "ub:undergraduateDegreeFrom"
54  var_12 = var_1_7_outEdges[i_var_12].property;
55  NodeId var_4; //corresponding to element having label "?Y"
56  var_4 = var_1_7_outEdges[i_var_12].node;
57  int cond_level_8 = (var_12 == p_var_12);
58  if(cond_level_8)
59  {
60  size_t in_degree_var_4 = getInDegree(graph, var_4);
61  Edge * var_4_9_inEdges = getInEdges(graph, var_4);
62  size_t i_var_11;
63  for(i_var_11=0; i_var_11 < in_degree_var_4; i_var_11++)
64  {
65  PropertyId var_11; //corresponding to element having label "ub:subOrganizationOf"
66  var_11 = var_4_9_inEdges[i_var_11].property;
67  NodeId var_7_10; //corresponding to element having label "?Z"
68  var_7_10 = var_4_9_inEdges[i_var_11].node;
69  int cond_level_10 = ((var_11 == p_var_11) & (var_7_10 == var_7));
70  if(cond_level_10)
71  {
72  size_t out_degree_var_4 = getOutDegree(graph, var_4);
73  Edge * var_4_11_outEdges = getOutEdges(graph, var_4);
74  size_t i_var_6;
75  for(i_var_6=0; i_var_6 < out_degree_var_4; i_var_6++)
76  {
77  PropertyId var_6; //corresponding to element having label "a"
78  var_6 = var_4_11_outEdges[i_var_6].property;
79  NodeId var_5; //corresponding to element having label "ub:University"
80  var_5 = var_4_11_outEdges[i_var_6].node;
81  int cond_level_12 = ((var_6 == p_var_6) & (var_5 == p_var_5));
82  if(cond_level_12)
83  {
84  // here the "required" results are written (if any)
85  localCounter++;
86  }
87  }
88  }
89  }
90  }
91  }
92  }
93  }
94  }
95  }
96  atomicIncrement(&(counter[i_var_3 % N_THREADS]), localCounter);
97  }
98 }
99 
100 __attribute__((noinline))
101 void parallel(Graph * graph, NodeId var_2, PropertyId p_var_3, PropertyId p_var_5, PropertyId p_var_6, PropertyId p_var_8, PropertyId p_var_9, PropertyId p_var_10, PropertyId p_var_11, PropertyId p_var_12, size_t in_degree_var_2, Edge * var_2_1_inEdges)
102 {
103  size_t i_var_3;
104  #pragma omp parallel for
105  for(i_var_3=0; i_var_3 < in_degree_var_2; i_var_3++)
106  {
107  kernel(i_var_3, graph, var_2, p_var_3, p_var_5, p_var_6, p_var_8, p_var_9, p_var_10, p_var_11, p_var_12, in_degree_var_2, var_2_1_inEdges);
108  }
109 }
110 
111 __attribute__((noinline))
112 int search(Graph * graph, NodeId var_2, PropertyId p_var_3, PropertyId p_var_5, PropertyId p_var_6, PropertyId p_var_8, PropertyId p_var_9, PropertyId p_var_10, PropertyId p_var_11, PropertyId p_var_12)
113 {
114  size_t in_degree_var_2 = getInDegree(graph, var_2);
115 #ifndef NDEBUG
116  printf("In degree %d\n", in_degree_var_2);
117 #endif
118  Edge * var_2_1_inEdges = getInEdges(graph, var_2);
119  parallel(graph, var_2, p_var_3, p_var_5, p_var_6, p_var_8, p_var_9, p_var_10, p_var_11, p_var_12, in_degree_var_2, var_2_1_inEdges);
120  for (int i = 0; i < N_THREADS; ++i)
121  numAnswers += counter[i];
122  return numAnswers;
123 }
124 
125 
126 int test(NodeId var_2, PropertyId p_var_3, PropertyId p_var_5, PropertyId p_var_6, PropertyId p_var_8, PropertyId p_var_9, PropertyId p_var_10, PropertyId p_var_11, PropertyId p_var_12)
127 {
128 #if defined(DATASETInVertexFile) && defined(DATASETOutVertexFile) && defined(DATASETInEdgeFile) && defined(DATASETOutEdgeFile)
129  loadGraph(DATASETInVertexFile, DATASETOutVertexFile, DATASETInEdgeFile, DATASETOutEdgeFile);
130 #else
131  //loadGraph("dataset/40-InVertexFile.bin", "dataset/40-OutVertexFile.bin", "dataset/40-InEdgeFile.bin", "dataset/40-OutEdgeFile.bin");
132  loadGraph("dataset/1-InVertexFile.bin", "dataset/1-OutVertexFile.bin", "dataset/1-InEdgeFile.bin", "dataset/1-OutEdgeFile.bin");
133 #endif
134 
135 // var_2 = "ub:Undergraduate-Student" 14398
136 // p_var_3 = "a" 14
137 // p_var_5 = "ub:University" 11347
138 // p_var_6 = "a" 14
139 // p_var_8 = "ub:Department" 11412
140 // p_var_9 = "a" 14
141 // p_var_10 = "ub:memberOf" 4
142 // p_var_11 = "ub:subOrganizationOf" 5
143 // p_var_12 = "ub:undergraduateDegreeFrom" 6 0
144  int ret_value = search(&TheGraph, var_2, p_var_3, p_var_5, p_var_6, p_var_8, p_var_9, p_var_10, p_var_11, p_var_12);
145 #ifndef NDEBUG
146  printf("%d\n", ret_value);
147 #endif
148  return ret_value;
149 }
150 
151 #ifndef NDEBUG
152 int main() {
153  return test(25273, 10, 1685, 10, 1828, 10, 4, 14, 3) != 0;
154  //return test(74, 14, 11347, 14, 11412, 14, 4, 5, 0);
155 }
156 #endif
PropertyId property
Definition: simple_API.h:18
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
int test(NodeId var_2, PropertyId p_var_3, PropertyId p_var_5, PropertyId p_var_6, PropertyId p_var_8, PropertyId p_var_9, PropertyId p_var_10, PropertyId p_var_11, PropertyId p_var_12)
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
int main()
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
void loadGraph(char *InVertexFileName, char *OutVertexFileName, char *InEdgeFileName, char *OutEdgeFileName)
Definition: load_graph.c:10
unsigned counter[N_THREADS]
Definition: data.c:3
__attribute__((noinline))
Convert the given fixedpt number to a decimal string.
unsigned numAnswers
Definition: data.c:5

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