PandA-2024.02
lubm_trinityq2.c
Go to the documentation of this file.
1 #include "simple_API.h"
2 #include <stdio.h>
3 
4 __attribute__((noinline)) void kernel(size_t i_var_3, Graph* graph, NodeId var_2, PropertyId p_var_3,
5  PropertyId p_var_5, Edge* var_2_1_inEdges)
6 {
7  unsigned localCounter = 0;
8  PropertyId var_3; // corresponding to element having label "a"
9  var_3 = var_2_1_inEdges[i_var_3].property;
10  NodeId var_1; // corresponding to element having label "?X"
11  var_1 = var_2_1_inEdges[i_var_3].node;
12  int cond_level_2 = (var_3 == p_var_3);
13  if(cond_level_2)
14  {
15  size_t out_degree_var_1 = getOutDegree(graph, var_1);
16  Edge* var_1_3_outEdges = getOutEdges(graph, var_1);
17  size_t i_var_5;
18  for(i_var_5 = 0; i_var_5 < out_degree_var_1; i_var_5++)
19  {
20  PropertyId var_5; // corresponding to element having label "ub:name"
21  var_5 = var_1_3_outEdges[i_var_5].property;
22  NodeId var_4; // corresponding to element having label "?Y"
23  var_4 = var_1_3_outEdges[i_var_5].node;
24  int cond_level_4 = (var_5 == p_var_5);
25  if(cond_level_4)
26  {
27  // here the "required" results are written (if any)
28  localCounter++;
29  }
30  }
31  atomicIncrement(&(counter[i_var_3 % N_THREADS]), localCounter);
32  }
33 }
34 
35 __attribute__((noinline)) void parallel(Graph* graph, NodeId var_2, PropertyId p_var_3, PropertyId p_var_5,
36  Edge* var_2_1_inEdges, size_t in_degree_var_2)
37 {
38  size_t i_var_3;
39 #pragma omp parallel for
40  for(i_var_3 = 0; i_var_3 < in_degree_var_2; i_var_3++)
41  {
42  kernel(i_var_3, graph, var_2, p_var_3, p_var_5, var_2_1_inEdges);
43  }
44 }
45 
46 __attribute__((noinline)) int search(Graph* graph, NodeId var_2, PropertyId p_var_3, PropertyId p_var_5)
47 {
48  size_t in_degree_var_2 = getInDegree(graph, var_2);
49 #ifndef NDEBUG
50  printf("In degree %d\n", in_degree_var_2);
51 #endif
52  Edge* var_2_1_inEdges = getInEdges(graph, var_2);
53  parallel(graph, var_2, p_var_3, p_var_5, var_2_1_inEdges, in_degree_var_2);
54 
55  for(int i = 0; i < N_THREADS; ++i)
56  numAnswers += counter[i];
57  return numAnswers;
58 }
59 
60 int test(NodeId var_2, PropertyId p_var_3, PropertyId p_var_5)
61 {
62 #if defined(DATASETInVertexFile) && defined(DATASETOutVertexFile) && defined(DATASETInEdgeFile) && \
63  defined(DATASETOutEdgeFile)
64  loadGraph(DATASETInVertexFile, DATASETOutVertexFile, DATASETInEdgeFile, DATASETOutEdgeFile);
65 #else
66  // loadGraph("dataset/40-InVertexFile.bin", "dataset/40-OutVertexFile.bin", "dataset/40-InEdgeFile.bin",
67  // "dataset/40-OutEdgeFile.bin");
68  loadGraph("dataset/1-InVertexFile.bin", "dataset/1-OutVertexFile.bin", "dataset/1-InEdgeFile.bin",
69  "dataset/1-OutEdgeFile.bin");
70 #endif
71 
72  // var_2 = "ub:Course" 16329
73  // p_var_3 = "a" 14
74  // p_var_5 = "ub:name" 17
75  int ret_value = search(&TheGraph, var_2, p_var_3, p_var_5);
76 #ifndef NDEBUG
77  printf("%d\n", ret_value);
78 #endif
79  return ret_value;
80 }
81 
82 #ifndef NDEBUG
83 int main()
84 {
85  return test(2473, 10, 8) != 828;
86 }
87 #endif
PropertyId property
Definition: simple_API.h:18
unsigned int PropertyId
Definition: simple_API.h:13
unsigned int NodeId
Definition: simple_API.h:11
int main()
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
int test(NodeId var_2, PropertyId p_var_3, PropertyId p_var_5)
#define N_THREADS
Definition: simple_API.h:7
__attribute__((noinline))
Convert the given fixedpt number to a decimal string.
Definition: lubm_trinityq2.c:4
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