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