PandA-2024.02
lubm_trinityq6.c
Go to the documentation of this file.
1 #include "simple_API.h"
2 #include <stdio.h>
3 
4 // var_2 = "<http://www.University0.edu>"
5 // p_var_3 = "ub:subOrganizationOf"
6 // p_var_4 = "ub:Department"
7 // p_var_5 = "a"
8 // p_var_7 = "ub:worksFor"
9 // p_var_8 = "ub:FullProfessor"
10 // p_var_9 = "a"
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_8,
14  PropertyId p_var_9, 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:subOrganizationOf"
18  var_3 = var_2_1_inEdges[i_var_3].property;
19  NodeId var_1; // corresponding to element having label "?Y"
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 in_degree_var_1 = getInDegree(graph, var_1);
25  Edge* var_1_3_inEdges = getInEdges(graph, var_1);
26  size_t i_var_7;
27  for(i_var_7 = 0; i_var_7 < in_degree_var_1; i_var_7++)
28  {
29  PropertyId var_7; // corresponding to element having label "ub:worksFor"
30  var_7 = var_1_3_inEdges[i_var_7].property;
31  NodeId var_6; // corresponding to element having label "?X"
32  var_6 = var_1_3_inEdges[i_var_7].node;
33  int cond_level_4 = (var_7 == p_var_7);
34  if(cond_level_4)
35  {
36  size_t out_degree_var_6 = getOutDegree(graph, var_6);
37  Edge* var_6_5_outEdges = getOutEdges(graph, var_6);
38  size_t i_var_9;
39  for(i_var_9 = 0; i_var_9 < out_degree_var_6; i_var_9++)
40  {
41  PropertyId var_9; // corresponding to element having label "a"
42  var_9 = var_6_5_outEdges[i_var_9].property;
43  NodeId var_8; // corresponding to element having label "ub:FullProfessor"
44  var_8 = var_6_5_outEdges[i_var_9].node;
45  int cond_level_6 = ((var_9 == p_var_9) & (var_8 == p_var_8));
46  if(cond_level_6)
47  {
48  size_t out_degree_var_1 = getOutDegree(graph, var_1);
49  Edge* var_1_7_outEdges = getOutEdges(graph, var_1);
50  size_t i_var_5;
51  for(i_var_5 = 0; i_var_5 < out_degree_var_1; i_var_5++)
52  {
53  PropertyId var_5; // corresponding to element having label "a"
54  var_5 = var_1_7_outEdges[i_var_5].property;
55  NodeId var_4; // corresponding to element having label "ub:Department"
56  var_4 = var_1_7_outEdges[i_var_5].node;
57  int cond_level_8 = ((var_5 == p_var_5) & (var_4 == p_var_4));
58  if(cond_level_8)
59  {
60  // here the "required" results are written (if any)
61  localCounter++;
62  }
63  }
64  }
65  }
66  }
67  }
68  atomicIncrement(&(counter[i_var_3 % N_THREADS]), localCounter);
69  }
70 }
71 
72 __attribute__((noinline)) void parallel(Graph* graph, NodeId var_2, PropertyId p_var_3, PropertyId p_var_4,
73  PropertyId p_var_5, PropertyId p_var_7, PropertyId p_var_8, PropertyId p_var_9,
74  size_t in_degree_var_2, Edge* var_2_1_inEdges)
75 {
76  size_t i_var_3;
77 #pragma omp parallel for
78  for(i_var_3 = 0; i_var_3 < in_degree_var_2; i_var_3++)
79  {
80  kernel(i_var_3, graph, var_2, p_var_3, p_var_4, p_var_5, p_var_7, p_var_8, p_var_9, in_degree_var_2,
81  var_2_1_inEdges);
82  }
83 }
84 
85 __attribute__((noinline)) int search(Graph* graph, NodeId var_2, PropertyId p_var_3, PropertyId p_var_4,
86  PropertyId p_var_5, PropertyId p_var_7, PropertyId p_var_8, PropertyId p_var_9)
87 {
88  size_t in_degree_var_2 = getInDegree(graph, var_2);
89 #ifndef NDEBUG
90  printf("In degree %d\n", in_degree_var_2);
91 #endif
92  Edge* var_2_1_inEdges = getInEdges(graph, var_2);
93  parallel(graph, var_2, p_var_3, p_var_4, p_var_5, p_var_7, p_var_8, p_var_9, in_degree_var_2, var_2_1_inEdges);
94  for(int i = 0; i < N_THREADS; ++i)
95  numAnswers += counter[i];
96  return numAnswers;
97 }
98 
99 int test(NodeId var_2, PropertyId p_var_3, PropertyId p_var_4, PropertyId p_var_5, PropertyId p_var_7,
100  PropertyId p_var_8, PropertyId p_var_9)
101 {
102 #if defined(DATASETInVertexFile) && defined(DATASETOutVertexFile) && defined(DATASETInEdgeFile) && \
103  defined(DATASETOutEdgeFile)
104  loadGraph(DATASETInVertexFile, DATASETOutVertexFile, DATASETInEdgeFile, DATASETOutEdgeFile);
105 #else
106  // loadGraph("dataset/40-InVertexFile.bin", "dataset/40-OutVertexFile.bin", "dataset/40-InEdgeFile.bin",
107  // "dataset/40-OutEdgeFile.bin");
108  loadGraph("dataset/1-InVertexFile.bin", "dataset/1-OutVertexFile.bin", "dataset/1-InEdgeFile.bin",
109  "dataset/1-OutEdgeFile.bin");
110 #endif
111 
112  // var_2 = "<http://www.University0.edu>" 6231
113  // p_var_3 = "ub:subOrganizationOf" 5
114  // p_var_4 = "ub:Department" 11412
115  // p_var_5 = "a" 14
116  // p_var_7 = "ub:worksFor" 16
117  // p_var_8 = "ub:FullProfessor" 21219
118  // p_var_9 = "a" 14
119  int ret_value = search(&TheGraph, var_2, p_var_3, p_var_4, p_var_5, p_var_7, p_var_8, p_var_9);
120 
121 #ifndef NDEBUG
122  printf("%d\n", ret_value);
123 #endif
124  return ret_value;
125 }
126 
127 #ifndef NDEBUG
128 int main()
129 {
130  return test(7293, 14, 1828, 10, 2, 6764, 10) != 125;
131 }
132 #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
__attribute__((noinline))
Convert the given fixedpt number to a decimal string.
NodeId node
Definition: simple_API.h:17
static size_t getInDegree(Graph *graph, NodeId node)
Definition: simple_API.h:45
int test(NodeId var_2, PropertyId p_var_3, PropertyId p_var_4, PropertyId p_var_5, PropertyId p_var_7, PropertyId p_var_8, PropertyId p_var_9)
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
void loadGraph(char *InVertexFileName, char *OutVertexFileName, char *InEdgeFileName, char *OutEdgeFileName)
Definition: load_graph.c:10
unsigned counter[N_THREADS]
Definition: data.c:3
int main()
unsigned numAnswers
Definition: data.c:5

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