-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add demonstrators for 4 code generation scenarios:
* a : Program initialization :https://HybroLangDemos/Newton-SquareRoot-VariablePrecision/Newton.hl * b : Kernel initialization : https://CodeExamples/Array-Mult-Specialization.hl * c : Applicaiton controlled : https://HybroLangDemos/Newton-SquareRoot-VariablePrecision/Newton.hl * d : Heterogeneous target : https://HybroLangDemos/ImagePixelSum/CxRAM-ImagePixelAccumulation.hl * Correct minor bugs (mul on cxram)
- Loading branch information
Henri-Pierre CHARLES
authored and
Henri-Pierre CHARLES
committed
May 22, 2023
1 parent
60e3654
commit a056def
Showing
22 changed files
with
380 additions
and
71 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 |
---|---|---|
@@ -1,15 +1,26 @@ | ||
2023-04-19 Henri-Pierre CHARLES HC227932 <hc227932@gre056290.intra.cea.fr> | ||
2023-05-22 Henri-Pierre CHARLES HC227932 <Henri-Pierre.Charles@cea.fr> | ||
|
||
* Add demonstrators for 4 code generation scenarios | ||
* a : Program initialization : | ||
https://HybroLangDemos/Newton-SquareRoot-VariablePrecision/Newton.hl | ||
* b : Kernel initialization : | ||
https://CodeExamples/Array-Mult-Specialization.hl | ||
* c : Applicaiton controlled : | ||
https://HybroLangDemos/Newton-SquareRoot-VariablePrecision/Newton.hl | ||
* d : Heterogeneous target : https://HybroLangDemos/ImagePixelSum/CxRAM-ImagePixelAccumulation.hl | ||
|
||
* Correct minor bugs (mul on cxram) | ||
|
||
2023-04-19 Henri-Pierre CHARLES HC227932 <Henri-Pierre.Charles@cea.fr> | ||
|
||
* Release 3.0: Target platforms risc-v, power, aarch64, cxram | ||
* More complex demonstrations | ||
* Sync with release 1.0 of https://github.com/CEA-LIST/csram-qemu-plugin | ||
|
||
|
||
2022-07-14 Henri-Pierre Charles <hc227932@gre061041> | ||
2022-07-14 Henri-Pierre Charles <hc227932@gre056290.intra.cea.fr> | ||
|
||
* Target platforms : partial part of the ISA of RISCV, Power, | ||
Kalray, CxRAM platforms | ||
|
||
* Release 2.0: First public release | ||
|
||
|
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,86 @@ | ||
// -*- c -*- | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <time.h> | ||
|
||
typedef int (*pifi)(int *, int); | ||
|
||
|
||
h2_insn_t * genMulArray(h2_insn_t * ptr, int b) | ||
{ | ||
#[ | ||
int 32 1 mult (int[] 32 1 a, int 32 1 len) | ||
{ | ||
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 | ||
} | ||
} | ||
]# | ||
return (h2_insn_t *) ptr; | ||
} | ||
|
||
void printArray(int * array, int len) | ||
{ | ||
printf ("Array values (%d) : ", len); | ||
for (int i = 0; i < len; i++) | ||
printf ("%d ", array[i]); | ||
printf ("\n"); | ||
} | ||
|
||
void mulArray(int * array, int len, int value) | ||
{ | ||
for (int i = 0; i < len; i++) | ||
array[i] = array[i] * value; | ||
} | ||
|
||
int main(int argc, char * argv[]) | ||
{ | ||
|
||
h2_insn_t * ptr; | ||
int arrayLen, mulValue, i, resultOK; | ||
pifi fPtr; | ||
int *array1, *array2; | ||
clock_t startC, stopC, startHg, stopHg; | ||
|
||
if (argc < 3) | ||
{ | ||
printf("Give 2 values (array len & mult. coefficient )\n"); | ||
exit(-1); | ||
} | ||
arrayLen = atoi (argv[1]); // Get the | ||
mulValue = atoi (argv[2]); | ||
array1 = calloc (arrayLen, sizeof (int)); | ||
array2 = calloc (arrayLen, sizeof (int)); | ||
for (i = 0; i < arrayLen; i++) | ||
{ | ||
array1[i] = random () % 100; | ||
array2[i] = array1[i]; | ||
} | ||
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); | ||
startHg = clock(); | ||
fPtr(array1, arrayLen); // Call generated code | ||
stopHg = clock(); | ||
printArray (array1, arrayLen); | ||
resultOK = 0; | ||
startC = clock(); | ||
mulArray (array2, arrayLen, mulValue); | ||
stopC = clock(); | ||
printf ("C version %ld Hg version %ld\n\n", stopC - startC, stopHg - startHg); | ||
for (int i = 0; i < arrayLen; i++) | ||
{ | ||
if (array2[i] != array1[i]) | ||
{ | ||
printf("Erreur multiplication!\n"); | ||
resultOK = -1; | ||
break; | ||
} | ||
} | ||
return resultOK; | ||
} |
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
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
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
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
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
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
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
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
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
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
Oops, something went wrong.