harvard-acc / ALADDIN

A pre-RTL, power-performance model for fixed-function accelerators
Other
161 stars 54 forks source link

Simulate AES from MachSuite using Aladdin #7

Closed liangwang closed 8 years ago

liangwang commented 8 years ago

I tried to generate trace using LLVM-tracer as follows:

export WORKLOAD=aes256_encrypt_ecb
clang -g -O1 -static -S -fno-slp-vectorize -fno-vectorize -fno-unroll-loops -fno-inline -emit-llvm -o aes.llvm aes.c
opt -S -load=$(TRACER_HOME)/full-trace/full_trace.so -fulltrace aes.llvm -o aes-opt.llvm
llvm-link -o full.llvm aes-opt.llvm $(TRACER_HOME)/profile-func/trace_logger.llvm
llc -filetype=asm -o full.s full.llvm
gcc -static -fno-inline -o aes-instrumented full.s ../../common/harness.c -lz -lm
./aes-instrumented input.data check.data

The trace was successfully generated, then I tried to simulate aes with Aladdin using the following configuration saved in "config_example":

unrolling,aes256_encrypt_ecb,5,2
pipelining,1
cycle_time,6

and invoked Aladdin as:

aladdin aes dynamic_trace.gz config_excample

Unfortunately, Aladdin aborted with the following errors:

Unknown partition :  rcon@inst: 1

Could anyone help on resolve this issue? Or maybe I should ask at the very beginning, is Aladdin able to simulate benchmarks from MachSuite? Sorry if this is not the right place to ask for help. Please point me to the right place, since I did not see any user mailing list or something similar from Aladdin's project page.

Thanks for releasing the great Aladdin tool!

ysshao commented 8 years ago

Hi @liangwang , great to hear from you! We have been using Aladdin simulating MachSuite benchmarks for a while, so it's definitely doable. The issues that you run into can be solved with the following config file: (I'll explain why it's the case in a minute.)

cycle_time,6 pipelining,1 partition,cyclic,ctx,96,1,1 partition,cyclic,k,32,1,1 partition,cyclic,buf,16,1,1 partition,complete,rcon,1 partition,cyclic,sbox,256,1,1 flatten,gf_alog,73 flatten,gf_log,83 flatten,aes_subBytes,122 flatten,aes_addRoundKey,130 flatten,aes_addRoundKey_cpy,138 flatten,aes_mixColumns,159 flatten,aes_expandEncKey,179 flatten,aes_expandEncKey,186 unrolling,aes256_encrypt_ecb,203,1 unrolling,aes256_encrypt_ecb,206,1 unrolling,aes256_encrypt_ecb,212,1

First, LLVM-Tracer doesn't automatically trace the sub functions. In the aes example, although we have already declared that WORKLOAD is aes256_encrypt_ecb, we still need to declare the rest of functions that aes256_encrypt_ecb calls to get a complete trace. When we set the WORKLOAD environment, we need to list all the functions that we want to track, basically all the functions that we want to build accelerators for, and separate them by comma, e.g., export WORKLOAD=aes256_encrypt_ecb,aes_subBytes,aes_addRoundKey,aes_addRoundKey_cpy,...

Second, on rcon, because it's used as a pointer in the code example, in the LLVM IR trace, accessing rcon is treated as memory references. That's why we got the Aladdin error msg that rcon is unknown. To solve that, we can declare rcon as a completely partitioned register.

Hopefully this should solve the problem. Let me know if you run into any issues.

Thanks, Sophia

BTW, you can definitely reach us here. We also start setting up a google user's group, you can find it here:

https://groups.google.com/forum/#!forum/aladdin

We just set it up, so there is no much traffic yet. But feel free to post questions there as well.

ysshao commented 8 years ago

Hi @liangwang , is the issue resolved?

liangwang commented 8 years ago

Oh, my bad, my previous comment was missing!

Yes, your comments solve the issue. Could you share the setups for other MachSuite benchmarks? More of a suggestion than a request, it would be nice to have the out-of-box support for the MachSuite benchmarks, or some guidance/tutorial to use Aladdin with MachSuite.

ysshao commented 8 years ago

Yeah good point @liangwang ! we do have an automatic interface to set up Aladdin simulations for MachSuite. We need to do some code cleanup here but we will release our setup later to make it easier for other users to use Aladdin w/ MachSuite.