#make(五)Try running test code
#./bin/aes_test -m ENC ------------------------------------------ AES-128-CBC ENC, Size: 16KB ------------------------------------------ #msg latency(usec) thruput(Mbps) 1 6012 21 2 6305 41 4 7020 74 8 8737 120 16 11834 177 32 16168 259 64 17244 486 128 19256 871 256 24579 1365 512 27067 2479 1024 31605 4246 2048 40924 6559 4096 61402 8743 Correctness check (batch, random): .............OK #./bin/rsa_test -m MP -snip- #./bin/sha_test -snip-you can see more detailed usage by running program w/o arguments or w/ incorrect one :).
device_context dev_ctx;
pinned_mem_pool *pool;
aes_enc_param_t param;
operation_batch_t ops;
//1. initialize device context
dev_ctx.init(num_flows * flow_len * 3, 0);
//2. create aes_context.
aes_context aes_ctx(&dev_ctx);
//generate test random test case
gen_aes_cbc_data(&ops,
key_bits,
num_flows,
flow_len,
true);
//3. prepare data to be encrypted
pool = new pinned_mem_pool();
pool->init(num_flows * flow_len * 3);
aes_cbc_encrypt_prepare(&ops, ¶m, pool);
//4. Launch GPU code
aes_ctx.cbc_encrypt(param.memory_start,
param.in_pos,
param.key_pos,
param.ivs_pos,
param.pkt_offset_pos,
param.tot_in_len,
param.out,
param.num_flows,
param.tot_out_len,
0);
//5. Wait for completion
aes_ctx.sync(0);
(一)
Initialize device_context:
libgpucrypto has several wrapper for CUDA initialization and stream manipulation.
To utilize libgpucrypto, you need to create
device_context .