-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tutorials update Co-authored-by: Serena Curzel <serena.curzel@mail.polimi.it>
- Loading branch information
Showing
112 changed files
with
35,309 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
unsigned short icrc1(unsigned short crc, unsigned char onech) | ||
{ | ||
int i; | ||
unsigned short ans=(crc^onech << 8); | ||
|
||
for (i=0;i<8;i++) { | ||
if (ans & 0x8000) | ||
ans = (ans <<= 1) ^ 4129; | ||
else | ||
ans <<= 1; | ||
} | ||
return ans; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0"?> | ||
<function> | ||
<testbench crc="6452" onech="5" /> | ||
<testbench crc="942856" onech="3" /> | ||
</function> |
10 changes: 10 additions & 0 deletions
10
documentation/everest_summer_school/Exercise2/gemm_32.c.interface.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0"?> | ||
<module> | ||
<function id="gemm_32"> | ||
<arg id="P0" interface_type="default" interface_typename="float" interface_typename_orig="float" interface_typename_include=""/> | ||
<arg id="P1" interface_type="default" interface_typename="float" interface_typename_orig="float" interface_typename_include=""/> | ||
<arg id="P2" interface_type="array" interface_typename="float *" interface_typename_orig="float *" size="1024" interface_typename_include=""/> | ||
<arg id="P3" interface_type="array" interface_typename="float *" interface_typename_orig="float *" size="1024" interface_typename_include=""/> | ||
<arg id="P4" interface_type="array" interface_typename="float *" interface_typename_orig="float *" size="1024" interface_typename_include=""/> | ||
</function> | ||
</module> |
19 changes: 19 additions & 0 deletions
19
documentation/everest_summer_school/Exercise2/gemm_32.mlir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
func @gemm_32(%alpha: f32, %beta: f32, %C: memref<32x32xf32>, %A: memref<32x32xf32>, %B: memref<32x32xf32>) { | ||
affine.for %i = 0 to 32 { | ||
affine.for %j = 0 to 32 { | ||
%0 = affine.load %C[%i, %j] : memref<32x32xf32> | ||
%1 = mulf %beta, %0 : f32 | ||
affine.store %1, %C[%i, %j] : memref<32x32xf32> | ||
affine.for %k = 0 to 32 { | ||
%2 = affine.load %A[%i, %k] : memref<32x32xf32> | ||
%3 = affine.load %B[%k, %j] : memref<32x32xf32> | ||
%4 = affine.load %C[%i, %j] : memref<32x32xf32> | ||
%5 = mulf %alpha, %2 : f32 | ||
%6 = mulf %5, %3 : f32 | ||
%7 = addf %4, %6 : f32 | ||
affine.store %7, %C[%i, %j] : memref<32x32xf32> | ||
} | ||
} | ||
} | ||
return | ||
} |
9 changes: 9 additions & 0 deletions
9
documentation/everest_summer_school/Exercise2/gemm_32_test.xml
Large diffs are not rendered by default.
Oops, something went wrong.
15 changes: 15 additions & 0 deletions
15
documentation/everest_summer_school/Exercise2/helmholtz.c.interface.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0"?> | ||
<module> | ||
<function id="gemm_32"> | ||
<arg id="P0" interface_type="array" interface_typename="double *" interface_typename_orig="double *" size="121" interface_typename_include=""/> | ||
<arg id="P1" interface_type="array" interface_typename="double *" interface_typename_orig="double *" size="1331" interface_typename_include=""/> | ||
<arg id="P2" interface_type="array" interface_typename="double *" interface_typename_orig="double *" size="1331" interface_typename_include=""/> | ||
<arg id="P3" interface_type="array" interface_typename="double *" interface_typename_orig="double *" size="1331" interface_typename_include=""/> | ||
<arg id="P4" interface_type="array" interface_typename="double *" interface_typename_orig="double *" size="1331" interface_typename_include=""/> | ||
<arg id="P5" interface_type="array" interface_typename="double *" interface_typename_orig="double *" size="1331" interface_typename_include=""/> | ||
<arg id="P6" interface_type="array" interface_typename="double *" interface_typename_orig="double *" size="1331" interface_typename_include=""/> | ||
<arg id="P7" interface_type="array" interface_typename="double *" interface_typename_orig="double *" size="1331" interface_typename_include=""/> | ||
<arg id="P8" interface_type="array" interface_typename="double *" interface_typename_orig="double *" size="1331" interface_typename_include=""/> | ||
<arg id="P9" interface_type="array" interface_typename="double *" interface_typename_orig="double *" size="1331" interface_typename_include=""/> | ||
</function> | ||
</module> |
107 changes: 107 additions & 0 deletions
107
documentation/everest_summer_school/Exercise2/helmholtz.mlir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
#le_10 = affine_set<(i): (10 - i >= 0)> | ||
#ge_10 = affine_set<(i): (i - 10 >= 0)> | ||
#eq_0_le_10 = affine_set<(i, j): (i == 0, 10 - j >= 0)> | ||
#eq_10 = affine_set<(i): (i - 10 == 0)> | ||
|
||
module { | ||
|
||
func @kernel(%S: memref<11x11xf64>{ llvm.name = "S" }, %D: memref<11x11x11xf64>{ llvm.name = "D" }, %u: memref<11x11x11xf64>{ llvm.name = "u" }, %v: memref<11x11x11xf64>{ llvm.name = "v" }, %t: memref<11x11x11xf64>{ llvm.name = "t" }, %r: memref<11x11x11xf64>{ llvm.name = "r" }, %t0: memref<11x11x11xf64>{ llvm.name = "t0" }, %t1: memref<11x11x11xf64>{ llvm.name = "t1" }, %t2: memref<11x11x11xf64>{ llvm.name = "t2" }, %t3: memref<11x11x11xf64>{ llvm.name = "t3" }) { | ||
%zero = std.constant 0.0 : f64 | ||
|
||
affine.for %c1 = 0 to 10 { | ||
affine.for %c2 = 0 to 10 { | ||
affine.for %c3 = 0 to 10 { | ||
affine.store %zero, %t1[%c1,%c2,%c3] : memref<11x11x11xf64> | ||
affine.for %c4 = 0 to 20 { | ||
affine.if #le_10(%c4) { | ||
%1 = affine.load %S[%c1,%c4] : memref<11x11xf64> | ||
%2 = affine.load %u[%c2,%c3,%c4] : memref<11x11x11xf64> | ||
%3 = mulf %1, %2 : f64 | ||
%4 = affine.load %t1[%c1,%c2,%c3] : memref<11x11x11xf64> | ||
%5 = addf %3, %4 : f64 | ||
affine.store %5, %t1[%c1,%c2,%c3] : memref<11x11x11xf64> | ||
} | ||
affine.if #ge_10(%c4) { | ||
%1 = affine.load %S[%c3,%c4 - 10] : memref<11x11xf64> | ||
%2 = affine.load %t1[%c1,%c2,%c3] : memref<11x11x11xf64> | ||
%3 = mulf %1, %2 : f64 | ||
%4 = affine.load %t0[%c4 - 10,%c1,%c2] : memref<11x11x11xf64> | ||
%5 = addf %3, %4 : f64 | ||
affine.store %5, %t0[%c4 - 10,%c1,%c2] : memref<11x11x11xf64> | ||
} | ||
affine.if #eq_0_le_10(%c3,%c4) { | ||
affine.store %zero, %t0[%c4,%c1,%c2] : memref<11x11x11xf64> | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
affine.for %c1 = 0 to 10 { | ||
affine.for %c2 = 0 to 10 { | ||
affine.for %c3 = 0 to 10 { | ||
affine.store %zero, %t[%c1,%c2,%c3] : memref<11x11x11xf64> | ||
affine.for %c4 = 0 to 20 { | ||
affine.if #le_10(%c4) { | ||
%1 = affine.load %S[%c1,%c4] : memref<11x11xf64> | ||
%2 = affine.load %t0[%c2,%c3,%c4] : memref<11x11x11xf64> | ||
%3 = mulf %1, %2 : f64 | ||
%4 = affine.load %t[%c1,%c2,%c3] : memref<11x11x11xf64> | ||
%5 = addf %3, %4 : f64 | ||
affine.store %5, %t[%c1,%c2,%c3] : memref<11x11x11xf64> | ||
affine.if #eq_10(%c4) { | ||
%6 = affine.load %D[%c1,%c2,%c3]: memref<11x11x11xf64> | ||
%7 = affine.load %t[%c1,%c2,%c3]: memref<11x11x11xf64> | ||
%8 = mulf %6, %7 : f64 | ||
affine.store %8, %r[%c1,%c2,%c3] : memref<11x11x11xf64> | ||
} | ||
} | ||
affine.if #ge_10(%c4) { | ||
%1 = affine.load %S[%c3,%c4 - 10] : memref<11x11xf64> | ||
%2 = affine.load %t[%c1,%c2,%c3] : memref<11x11x11xf64> | ||
%3 = mulf %1, %2 : f64 | ||
%4 = affine.load %t3[%c4 - 10,%c1,%c2] : memref<11x11x11xf64> | ||
%5 = addf %3, %4 : f64 | ||
affine.store %5, %t3[%c4 - 10,%c1,%c2] : memref<11x11x11xf64> | ||
} | ||
affine.if #eq_0_le_10(%c3,%c4) { | ||
affine.store %zero, %t3[%c4,%c1,%c2] : memref<11x11x11xf64> | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
affine.for %c1 = 0 to 10 { | ||
affine.for %c2 = 0 to 10 { | ||
affine.for %c3 = 0 to 10 { | ||
affine.for %c4 = 0 to 10 { | ||
affine.if #eq_10(%c3) { | ||
affine.store %zero, %v[%c4,%c1,%c2] : memref<11x11x11xf64> | ||
} | ||
affine.if #eq_10(%c4) { | ||
affine.store %zero, %t2[%c1,%c2,%c3] : memref<11x11x11xf64> | ||
} | ||
%1 = affine.load %S[%c4,%c1] : memref<11x11xf64> | ||
%2 = affine.load %t3[%c2,%c3,%c4] : memref<11x11x11xf64> | ||
%3 = mulf %1, %2 : f64 | ||
%4 = affine.load %t2[%c1,%c2,%c3] : memref<11x11x11xf64> | ||
%5 = addf %3, %4 : f64 | ||
affine.store %5,%t2[%c1,%c2,%c3] : memref<11x11x11xf64> | ||
} | ||
affine.for %c4 = 10 to 20 { | ||
%1 = affine.load %S[%c3,%c4 - 10] : memref<11x11xf64> | ||
%2 = affine.load %t2[%c1,%c2,%c3] : memref<11x11x11xf64> | ||
%3 = mulf %1, %2 : f64 | ||
%4 = affine.load %v[%c4 - 10,%c1,%c2] : memref<11x11x11xf64> | ||
%5 = addf %3, %4 : f64 | ||
affine.store %5, %v[%c4 - 10,%c1,%c2] : memref<11x11x11xf64> | ||
} | ||
} | ||
} | ||
} | ||
|
||
return | ||
} | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
documentation/everest_summer_school/Exercise2/helmholtz_test.xml
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
script=$(readlink -e $0) | ||
root_dir=$(dirname $script) | ||
|
||
bambu $root_dir/trinityq4/lubm_trinityq4.c --top-fname=search \ | ||
$root_dir/common/atominIncrement.c $root_dir/common/data.c -I$root_dir/common/ \ | ||
--compiler=I386_GCC49 --experimental-set=BAMBU -O3 --std=c99 -fno-delete-null-pointer-checks \ | ||
--channels-type=MEM_ACC_11 --memory-allocation-policy=NO_BRAM \ | ||
--device-name=xc7vx690t-3ffg1930-VVD --clock-period=10 \ | ||
-DMAX_VERTEX_NUMBER=26455 -DMAX_EDGE_NUMBER=100573 -DN_THREADS=1 \ | ||
--mem-delay-read=20 --mem-delay-write=20 \ | ||
--generate-tb=$root_dir/test-1.xml --simulator=VERILATOR --simulate \ | ||
-v3 "$@" |& tee log.txt |
8 changes: 8 additions & 0 deletions
8
documentation/everest_summer_school/Exercise3/common/atominIncrement.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
__attribute__((noinline)) | ||
void atomicIncrement(unsigned * var, unsigned value) | ||
{ | ||
#pragma omp atomic | ||
*var += value; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include "simple_API.h" | ||
|
||
unsigned counter[N_THREADS] = { 0 }; | ||
|
||
unsigned numAnswers = 0; | ||
|
||
Graph TheGraph; | ||
|
60 changes: 60 additions & 0 deletions
60
documentation/everest_summer_school/Exercise3/common/load_graph.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#include <stdio.h> | ||
#include <sys/types.h> | ||
#include <sys/stat.h> | ||
#include <fcntl.h> | ||
#include <unistd.h> | ||
#include <assert.h> | ||
#include "simple_API.h" | ||
|
||
void | ||
loadGraph(char * InVertexFileName, char * OutVertexFileName, char * InEdgeFileName, char * OutEdgeFileName) | ||
{ | ||
int IVF, OVF, IEF, OEF; | ||
|
||
IVF = open(InVertexFileName, O_RDONLY); | ||
assert(IVF != -1); | ||
OVF = open(OutVertexFileName, O_RDONLY); | ||
assert(OVF != -1); | ||
IEF = open(InEdgeFileName, O_RDONLY); | ||
assert(IEF != -1); | ||
OEF = open(OutEdgeFileName, O_RDONLY); | ||
assert(OEF != -1); | ||
|
||
unsigned int vertexNumber, secondvertexNumber; | ||
unsigned int inEdgeNumber; | ||
unsigned int outEdgeNumber; | ||
unsigned bytes_read; | ||
bytes_read = read(IVF, &vertexNumber, sizeof(unsigned int)); | ||
assert(bytes_read == sizeof(unsigned int)); | ||
bytes_read = read(OVF, &secondvertexNumber, sizeof(unsigned int)); | ||
assert(secondvertexNumber == vertexNumber); | ||
assert(bytes_read == sizeof(unsigned int)); | ||
|
||
bytes_read = read(IEF, &inEdgeNumber, sizeof(unsigned int)); | ||
assert(bytes_read == sizeof(unsigned int)); | ||
bytes_read = read(OEF, &outEdgeNumber, sizeof(unsigned int)); | ||
assert(bytes_read == sizeof(unsigned int)); | ||
|
||
TheGraph.numVertices = vertexNumber - 1; | ||
printf("VertexNumber : %lu\n", TheGraph.numVertices); | ||
printf("InEdgeNumber : %d\n", inEdgeNumber); | ||
printf("outEdgeNumber : %d\n", outEdgeNumber); | ||
|
||
bytes_read = read(IVF, TheGraph.inEdgesIDs, sizeof(TheGraph.inEdgesIDs[0]) * (TheGraph.numVertices + 1)); | ||
assert(bytes_read == sizeof(TheGraph.inEdgesIDs[0]) * (TheGraph.numVertices + 1)); | ||
bytes_read = read(OVF, TheGraph.outEdgesIDs, sizeof(TheGraph.outEdgesIDs[0]) * (TheGraph.numVertices + 1)); | ||
assert(bytes_read == sizeof(TheGraph.outEdgesIDs[0]) * (TheGraph.numVertices + 1)); | ||
|
||
bytes_read = read(IEF, TheGraph.inEdges, sizeof(Edge) * inEdgeNumber); | ||
assert(bytes_read == sizeof(Edge) * inEdgeNumber); | ||
bytes_read = read(OEF, TheGraph.outEdges, sizeof(Edge) * outEdgeNumber); | ||
assert(bytes_read == sizeof(Edge) * outEdgeNumber); | ||
|
||
printf("Graph Loading Completed!\n"); | ||
|
||
close(IVF); | ||
close(OVF); | ||
close(IEF); | ||
close(OEF); | ||
} | ||
|
79 changes: 79 additions & 0 deletions
79
documentation/everest_summer_school/Exercise3/common/simple_API.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#ifndef __GRAPH_H__ | ||
#define __GRAPH_H__ | ||
|
||
#include <stddef.h> | ||
|
||
#ifndef N_THREADS | ||
#define N_THREADS 8 | ||
#endif | ||
|
||
|
||
typedef unsigned int NodeId; | ||
typedef unsigned int EdgeId; | ||
typedef unsigned int PropertyId; | ||
|
||
|
||
typedef struct Edge { | ||
NodeId node; | ||
PropertyId property; | ||
} Edge; | ||
|
||
#ifndef MAX_VERTEX_NUMBER | ||
#define MAX_VERTEX_NUMBER 1309073 | ||
#endif | ||
|
||
#ifndef MAX_EDGE_NUMBER | ||
#define MAX_EDGE_NUMBER 5309056 | ||
#endif | ||
|
||
typedef struct Graph { | ||
size_t numVertices; | ||
// PropertyId * VertexPropertyVector; | ||
EdgeId outEdgesIDs[MAX_VERTEX_NUMBER]; | ||
EdgeId inEdgesIDs[MAX_VERTEX_NUMBER]; | ||
|
||
Edge inEdges[MAX_EDGE_NUMBER]; | ||
Edge outEdges[MAX_EDGE_NUMBER]; | ||
} Graph; | ||
|
||
|
||
//===----------------------------------------------------------------------===// | ||
// Backward Star Interface | ||
//===----------------------------------------------------------------------===// | ||
|
||
//size_t getInDegree(Graph * graph, NodeId node); | ||
static inline size_t getInDegree(Graph * graph, NodeId node) { | ||
return graph->inEdgesIDs[node+1] - graph->inEdgesIDs[node]; | ||
} | ||
|
||
//Edge * getInEdges(Graph * graph, NodeId node); | ||
static inline Edge * getInEdges(Graph * graph, NodeId node) { | ||
EdgeId idx = graph->inEdgesIDs[node]; | ||
return &graph->inEdges[idx]; | ||
} | ||
|
||
//===----------------------------------------------------------------------===// | ||
// Forward Star Interface | ||
//===----------------------------------------------------------------------===// | ||
|
||
//size_t getOutDegree(Graph * graph, NodeId node); | ||
static inline size_t getOutDegree(Graph * graph, NodeId node) { | ||
return graph->outEdgesIDs[node+1] - graph->outEdgesIDs[node]; | ||
} | ||
|
||
//Edge * getOutEdges(Graph * graph, NodeId node); | ||
static inline Edge * getOutEdges(Graph * graph, NodeId node) { | ||
EdgeId idx = graph->outEdgesIDs[node]; | ||
return &graph->outEdges[idx]; | ||
} | ||
|
||
extern void | ||
loadGraph(char * InVertexFileName, char * OutVertexFileName, char * InEdgeFileName, char * OutEdgeFileName); | ||
|
||
extern Graph TheGraph; | ||
|
||
extern unsigned numAnswers; | ||
|
||
extern unsigned counter[N_THREADS]; | ||
|
||
#endif /* __GRAPH_H__ */ |
Oops, something went wrong.