PandA-2024.02
lubm_trinityq7.c
Go to the documentation of this file.
1 #include "simple_API.h"
2 #include <stdio.h>
3 
4 // p_var_3 = "ub:teacherOf"
5 // var_4 = "ub:FullProfessor"
6 // p_var_5 = "a"
7 // p_var_6 = "ub:Course"
8 // p_var_7 = "a"
9 // p_var_9 = "ub:advisor"
10 // p_var_10 = "ub:UndergraduateStudent"
11 // p_var_11 = "a"
12 // p_var_12 = "ub:takesCourse"
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_1; // corresponding to element having label "?Y"
23  var_1 = 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_1 = getInDegree(graph, var_1);
28  Edge* var_1_3_inEdges = getInEdges(graph, var_1);
29  size_t i_var_9;
30  for(i_var_9 = 0; i_var_9 < in_degree_var_1; i_var_9++)
31  {
32  PropertyId var_9; // corresponding to element having label "ub:advisor"
33  var_9 = var_1_3_inEdges[i_var_9].property;
34  NodeId var_8; // corresponding to element having label "?X"
35  var_8 = var_1_3_inEdges[i_var_9].node;
36  int cond_level_4 = (var_9 == p_var_9);
37  if(cond_level_4)
38  {
39  size_t out_degree_var_8 = getOutDegree(graph, var_8);
40  Edge* var_8_5_outEdges = getOutEdges(graph, var_8);
41  size_t i_var_11;
42  for(i_var_11 = 0; i_var_11 < out_degree_var_8; i_var_11++)
43  {
44  PropertyId var_11; // corresponding to element having label "a"
45  var_11 = var_8_5_outEdges[i_var_11].property;
46  NodeId var_10; // corresponding to element having label "ub:UndergraduateStudent"
47  var_10 = var_8_5_outEdges[i_var_11].node;
48  int cond_level_6 = ((var_11 == p_var_11) & (var_10 == p_var_10));
49  if(cond_level_6)
50  {
51  size_t out_degree_var_1 = getOutDegree(graph, var_1);
52  Edge* var_1_7_outEdges = getOutEdges(graph, var_1);
53  size_t i_var_3;
54  for(i_var_3 = 0; i_var_3 < out_degree_var_1; i_var_3++)
55  {
56  PropertyId var_3; // corresponding to element having label "ub:teacherOf"
57  var_3 = var_1_7_outEdges[i_var_3].property;
58  NodeId var_2; // corresponding to element having label "?Z"
59  var_2 = var_1_7_outEdges[i_var_3].node;
60  int cond_level_8 = (var_3 == p_var_3);
61  if(cond_level_8)
62  {
63  size_t in_degree_var_2 = getInDegree(graph, var_2);
64  Edge* var_2_9_inEdges = getInEdges(graph, var_2);
65  size_t i_var_12;
66  for(i_var_12 = 0; i_var_12 < in_degree_var_2; i_var_12++)
67  {
68  PropertyId var_12; // corresponding to element having label "ub:takesCourse"
69  var_12 = var_2_9_inEdges[i_var_12].property;
70  NodeId var_8_10; // corresponding to element having label "?X"
71  var_8_10 = var_2_9_inEdges[i_var_12].node;
72  int cond_level_10 = ((var_12 == p_var_12) & (var_8_10 == var_8));
73  if(cond_level_10)
74  {
75  size_t out_degree_var_2 = getOutDegree(graph, var_2);
76  Edge* var_2_11_outEdges = getOutEdges(graph, var_2);
77  size_t i_var_7;
78  for(i_var_7 = 0; i_var_7 < out_degree_var_2; i_var_7++)
79  {
80  PropertyId var_7; // corresponding to element having label "a"
81  var_7 = var_2_11_outEdges[i_var_7].property;
82  NodeId var_6; // corresponding to element having label "ub:Course"
83  var_6 = var_2_11_outEdges[i_var_7].node;
84  int cond_level_12 = ((var_7 == p_var_7) & (var_6 == p_var_6));
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 
127  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,
128  var_4_1_inEdges);
129 
130  for(int i = 0; i < N_THREADS; ++i)
131  numAnswers += counter[i];
132  return numAnswers;
133 }
134 
135 int test(NodeId var_4, PropertyId p_var_3, PropertyId p_var_5, PropertyId p_var_6, PropertyId p_var_7,
136  PropertyId p_var_9, PropertyId p_var_10, PropertyId p_var_11, PropertyId p_var_12)
137 {
138 #if defined(DATASETInVertexFile) && defined(DATASETOutVertexFile) && defined(DATASETInEdgeFile) && \
139  defined(DATASETOutEdgeFile)
140  loadGraph(DATASETInVertexFile, DATASETOutVertexFile, DATASETInEdgeFile, DATASETOutEdgeFile);
141 #else
142  // loadGraph("dataset/40-InVertexFile.bin", "dataset/40-OutVertexFile.bin", "dataset/40-InEdgeFile.bin",
143  // "dataset/40-OutEdgeFile.bin");
144  loadGraph("dataset/1-InVertexFile.bin", "dataset/1-OutVertexFile.bin", "dataset/1-InEdgeFile.bin",
145  "dataset/1-OutEdgeFile.bin");
146 #endif
147 
148  // p_var_3 = "ub:teacherOf" 18
149  // var_4 = "ub:FullProfessor" 21219
150  // p_var_5 = "a" 14
151  // p_var_6 = "ub:Course" 16329
152  // p_var_7 = "a" 14
153  // p_var_9 = "ub:advisor" 8
154  // p_var_10 = "ub:UndergraduateStudent" 14398
155  // p_var_11 = "a" 14
156  // p_var_12 = "ub:takesCourse" 2
157  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);
158 #ifndef NDEBUG
159  printf("%d\n", ret_value);
160 #endif
161  return ret_value;
162 }
163 
164 #ifndef NDEBUG
165 int main()
166 {
167  return test(6764, 9, 10, 2473, 10, 1, 25273, 10, 7) != 30;
168  // return test(21219, 18, 14, 16329, 14, 8, 14398, 14, 2);
169 }
170 #endif
PropertyId property
Definition: simple_API.h:18
unsigned int PropertyId
Definition: simple_API.h:13
int main()
unsigned int NodeId
Definition: simple_API.h:11
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)
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
__attribute__((noinline))
Convert the given fixedpt number to a decimal string.
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
unsigned numAnswers
Definition: data.c:5

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