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