# Morpher-v2
## running steps
```bash=
# run these each time reconnect to the server
source venv/bin/activate
export PATH=$PATH:/home/ycpinlabpc/Desktop/lab-progress/morpher-v2/llvm-project/llvm-build/bin
```
```bash=
python -u run_morpher_llvm16.py morpher_benchmarks/array_add/array_add.c array_add
```
```bash=
# path to c code source file
/home/annyen1113/morpher-v2/dfg_generator/benchmarks/morpher_benchmarks
```

* Change the config directory in **run_morpher_llvm16.py** to run mapping on different cgra type
* Change the morpher_benchmarks/**array_add**/**array_add.c** **array_add** marked parts to run different dfg mapping
---
hpcg successfully mapped with config **config/alu_dependent_stdnoc.yaml**
---
## 2024/4/12
[LISA](https://hackmd.io/DcwC-y0NSlqJptGo8vAVYQ)
### array_cond_no_else

```cpp=
__attribute__((noinline))
void array_cond_no_else(){
int x;
for (int i=0;i<SIZE; i++){
#ifdef CGRA_COMPILER
please_map_me();
#endif
if (A[i] > B[i])
C[i] = A[i] - B[i];
```
### array_cond

```cpp=
__attribute__((noinline))
void array_cond(){
int x;
for (int i=0;i<SIZE; i++){
#ifdef CGRA_COMPILER
please_map_me();
#endif
if (A[i] > B[i])
C[i] = A[i] - B[i];
else
C[i] = A[i] + B[i];
```
### recursion example
```cpp=
#include <string.h>
#include <stdio.h>
#define SIZE 20
int A[SIZE], B[SIZE], C[SIZE];
__attribute__((noinline))
int factorial(int n)
{
#ifdef CGRA_COMPILER
please_map_me();
#endif
return n * factorial(n ‑ 1);
}
int main(){
int result;
result = factorial(10);
printf("%d\n", result);
return 0;
}
```
#### current result
unable to map recursion
