Skip to content

Commit

Permalink
Intégration de la V4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
CHARLES Henri-Pierre committed Nov 30, 2023
1 parent a056def commit 5b088f1
Show file tree
Hide file tree
Showing 40 changed files with 1,738 additions and 1,465 deletions.
36 changes: 36 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,39 @@
2023-11-30 Henri-Pierre Charles <hc227932@gre061041>

* Demonstrators for new article

* Upgrade GenCrossTool with new release tools

mpfr : 4.2.0
gmp : 6.2.1
mpc : 1.3.1
gcc : 13.2.0
binutils : 2.40
gdb : 10.1
linux : 5.18.17
newlib : 4.3.0.20230120
glibc : 2.37
qemu : 8.0.3
isl : 0.26


* Public V4.0 release

2023-09-18 Henri-Pierre Charles <hc227932@gre061041>

* Add aarch64 backend

* New language construction : initial if/else support: condition
with only one simple condition (like loops)

* New low level code generation optimisation. Multiplication by
runt time value 0 or power of 2 will be optimized

* New low level binary code generation scheme. if + return instead
of nested if

* V4.0 release

2023-05-22 Henri-Pierre CHARLES HC227932 <[email protected]>

* Add demonstrators for 4 code generation scenarios
Expand Down
9 changes: 4 additions & 5 deletions CodeExamples/Add-With-Specialization.hl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

typedef int (*pifi)(int);

h2_insn_t * genAdd(h2_insn_t * ptr, int b)
pifi genAdd(pifi ptr, int b)
{
#[
int 32 1 add (int 32 1 a)
Expand All @@ -14,12 +14,11 @@ h2_insn_t * genAdd(h2_insn_t * ptr, int b)
return r;
}
]#
return (h2_insn_t *) ptr;
return (pifi) ptr;
}

int main(int argc, char * argv[])
{
h2_insn_t * ptr;
int in0, in1, res;
pifi fPtr;

Expand All @@ -30,10 +29,10 @@ int main(int argc, char * argv[])
}
in0 = atoi (argv[1]); // Get the users values in1 & in2
in1 = atoi (argv[2]);
ptr = h2_malloc (1024); // Allocate memory for 1024 instructions
fPtr = (pifi) h2_malloc (1024); // Allocate memory for 1024 instructions
printf("// Compilette for simple addition between 1 variable with\n");
printf("// code specialization on value = %d\n", in0);
fPtr = (pifi) genAdd (ptr, in0); // Generate instructions
fPtr = genAdd (fPtr, in0); // Generate instructions
res = fPtr(in1); // Call generated code
printf("%d + %d = %d\n", in0, in1, res);
if (res == (in0 + in1))
Expand Down
26 changes: 12 additions & 14 deletions CodeExamples/Array-Mult-Specialization.hl
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@
#include <stdlib.h>
#include <time.h>

typedef int (*pifi)(int *, int);
typedef int (*pifi)(int *);


h2_insn_t * genMulArray(h2_insn_t * ptr, int b)
h2_insn_t * genMulArray(h2_insn_t * ptr, int b, int len)
{
#[
int 32 1 mult (int[] 32 1 a, int 32 1 len)
int 32 1 mult (int[] 32 1 a)
{
int 32 1 r, i;
for (i = 0; i < len; i = i + 1)
{
a[i] = a[i] * #(b); // b values will be included in code generation
int 32 1 r, i, l;
l = #(len);
for (i = 0; i < l; i = i + 1)
{ // b values will be included in code generation
a[i] = a[i] * #(b);
}
}
]#
Expand All @@ -37,8 +38,6 @@ void mulArray(int * array, int len, int value)

int main(int argc, char * argv[])
{

h2_insn_t * ptr;
int arrayLen, mulValue, i, resultOK;
pifi fPtr;
int *array1, *array2;
Expand All @@ -60,12 +59,11 @@ int main(int argc, char * argv[])
}
printArray (array1, arrayLen);
printf("// Multiply an array with a constant value\n");
printf("// Array len = %d\n", arrayLen);
printf("// Code specialization on value = %d\n", mulValue);
ptr = h2_malloc (1024); // Allocate memory for 1024 instructions
fPtr = (pifi) genMulArray (ptr, mulValue);
printf("// Array len = %d constant value %d\n", arrayLen, mulValue);
// Allocate memory for 1024 instructions, generate kernel
fPtr = (pifi) genMulArray (h2_malloc (1024), mulValue, arrayLen);
startHg = clock();
fPtr(array1, arrayLen); // Call generated code
fPtr(array1); // Call generated code
stopHg = clock();
printArray (array1, arrayLen);
resultOK = 0;
Expand Down
2 changes: 1 addition & 1 deletion CodeExamples/CelciusFarenheit.hl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ h2_insn_t * genC2F(h2_insn_t * ptr)
int 32 1 C2F (int 32 1 a)
{
int 32 1 r;
r = a * 9 / 5 + 32
r = a * 9 / 5 + 32;
return r;
}
]#
Expand Down
7 changes: 4 additions & 3 deletions CodeExamples/CxRAM-ImageDiff.hl
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ pifiii genSubImages(h2_insn_t * ptr)
#[
int 32 1 subImage(int[] 16 8 a, int[] 16 8 b, int[] 16 8 res, int 32 1 len)
{
int 32 1 i;
for (i = 0; i < len; i = i + 1)
int 32 1 i; // int 32 1 = RISC-V register
// int[] 16 8 = array of C-SRAM lines
for (i = 0; i < len; i = i + 1) // Control done on RISC-V
{
res[i] = a[i] - b[i];
res[i] = a[i] - b[i]; // Workload done on C-SRAM
}
}
return 0;
Expand Down
4 changes: 4 additions & 0 deletions CodeExamples/Regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ def cmd(cmdAndArgs, Verbose, doPrint = True, wdir = None, doExec = True):
"Array-Ld",
"Array-St-flt",
"Array-Ld-flt",
"Array-Mult-Specialization",
"Loop",
"LoopNest",
"If",
"If-in-Loop",
"Loop-in-If",
)
cxramTestList =(
"CxRAM-SimpleAnd",
Expand Down
16 changes: 10 additions & 6 deletions CodeExamples/RunDemo.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,13 @@
"Array-Ld" : (("3",), ("5",)),
"Array-St-flt" : (("3","12.0"), ("5","132.00")),
"Array-Ld-flt" : (("3",), ("5",)),
"Loop" : (("6", "7"), ("1000", "2"), ("2", "1000"), ),
"LoopNest" : (("1",), ("7",), ("42",)),
"Add8x16" : (("1.0", "2.0", "2.0", "1.0", "1.0", "1.0", "1.0", "1.0", "1.0", "1.0", "1.0", "1.0", "1.0", "1.0", "1.0", "1.0", )),
"Array-Mult-Specialization": (("10", "42",),),
"If" : (("42", "42"), ("4", "4"), ),
"If-in-Loop" : (("42", "42"), ("4", "4"), ),
"Loop-in-If" : (("1", "10"), ("0", "10"), ),
"Loop" : (("6", "7"), ("1000", "2"), ("2", "1000"), ),
"LoopNest" : (("1",), ("7",), ("42",)),
"Add8x16" : (("1.0", "2.0", "2.0", "1.0", "1.0", "1.0", "1.0", "1.0", "1.0", "1.0", "1.0", "1.0", "1.0", "1.0", "1.0", "1.0", )),
"CxRAM-SimpleSub8" : ( ("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", ),
("1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", ),
("10", "10", "10", "10", "10", "10", "10", "10", "10", "10", "10", "10", "10", "10", "10", "10", ),
Expand Down Expand Up @@ -120,16 +124,16 @@ def compile (File, Arch, Debug, Verbose):
cmdH2 = tuple(["../HybroLang.py", "--toC", "--arch"] + Arch + ["--inputfile", File+".hl"])
if Debug:
cmdH2 += ("--debug",)
compilerAndArg += ("-g", "-DH2_DEBUG")
compilerAndArg += ("-g", "-DH2_DEBUG", "-DASM_DEBUG")
if Verbose:
cmdH2 += ("--verbose",)
cmdH2 += ("--verboseParsing",)
o0 = cmd (["which", compilerAndArg[0]], Verbose)
if 0 != o0:
fatalError ("C Compiler not found (environment pb ?)", -1)
o1 = cmd(cmdH2, Verbose)
if 0 != o1:
fatalError ("Hybrogen compiler error", -2)
o2 = cmd(compilerAndArg + ("-Wall", "-o", File, File+".c"), Verbose)
o2 = cmd(compilerAndArg + ("-DQEMU_TARGET", "-Wall", "-o", File, File+".c"), Verbose)
if o2 != 0:
fatalError ("C compilation compiler error", -3)
return 0
Expand Down
Loading

0 comments on commit 5b088f1

Please sign in to comment.