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