Skip to content

Commit

Permalink
Move new translator to translator-v2, restore old translator
Browse files Browse the repository at this point in the history
  • Loading branch information
bozbez committed Dec 12, 2024
1 parent 892563a commit 3473b9a
Show file tree
Hide file tree
Showing 106 changed files with 29,714 additions and 0 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
26 changes: 26 additions & 0 deletions translator/c/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
### C/C++ Code Generators
This directory contains the OP2 code generators written in python targetting the C/C++ API. The parallelisations and optimisations supported by each generator are as follows:
* `op2_gen_seq.py`
* `op2_gen_openmp.py`: Initial OpenMP code generator.
* `op2_gen_openmp_simple.py`: Simplified and Optimized OpenMP code generator.
* `op2_gen_cuda.py`: Optimized for Fermi GPUs.
* `op2_gen_cuda_simple`: Optimized for Kepler GPUs.
* `op2_gen_cuda_simple_hyb.py`: Generates OpenMP code as well as CUDA code into the same file. Both CPUs and GPUs will then be used to do computations as a hybrid application.

#### Invoking the Code Generator
Uncomment the parallelization you want to code generate in `op2.py`. For example for CUDA code generation do:
```
#op2_gen_seq(str(sys.argv[1]), date, consts, kernels)
#op2_gen_openmp(str(sys.argv[1]), date, consts, kernels) # Initial OpenMP code generator
op2_gen_cuda(str(sys.argv[1]), date, consts, kernels,sets) # Optimized for Fermi GPUs
```

Make `op2.py` executable
```
chmod a+x ./op2.py
```

Invoke the code generator by supplying the files that contain op_* API calls. Thus for example for Airfoil do the following.
```
./op2.py airfoil.cpp
```
43 changes: 43 additions & 0 deletions translator/c/format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash
#Uses clang-format to format code to conform to the OP2 coding guidelines
# ... currently only applies to files within the current directory
# also only format the files producded by the code generator (i.e. files with kernel in their name)

#for file in ./*.cu ./*.cpp ./*.h ./*.hpp; do clang-format "$file" > "$file"_temp; mv "$file"_temp "$file"; done

ls ./*kernel* 2> /dev/null
if [ $? -eq 0 ]
then
for file in ./*kernel*; do clang-format -i "$file"; done
fi
ls ./*_op.cpp 2> /dev/null
if [ $? -eq 0 ]
then
for file in ./*_op.cpp; do clang-format -i "$file"; done
fi

#ls ./*.cu 2> /dev/null
#if [ $? -eq 0 ]
#then
# for file in ./*.cu; do clang-format -i "$file"; done
#fi
#ls ./*.c 2> /dev/null
#if [ $? -eq 0 ]
#then
# for file in ./*.c ; do clang-format -i "$file"; done
#fi
#ls ./*.cpp 2> /dev/null
#if [ $? -eq 0 ]
#then
# for file in ./*.cpp ; do clang-format -i "$file"; done
#fi
#ls ./*.h 2> /dev/null
#if [ $? -eq 0 ]
#then
# for file in ./*.h ; do clang-format -i "$file"; done
#fi
#ls ./*.hpp 2> /dev/null
#if [ $? -eq 0 ]
#then
# for file in ./*.hpp ; do clang-format -i "$file"; done
#fi
Loading

0 comments on commit 3473b9a

Please sign in to comment.