diff --git a/main.c b/main.c index 168ffd7..4d642a7 100644 --- a/main.c +++ b/main.c @@ -1224,7 +1224,8 @@ redo: rctx = tdat->rctx; reset_dedupe_context(tdat->rctx); rctx->cbuf = tdat->uncompressed_chunk; - dedupe_index_sz = dedupe_compress(tdat->rctx, tdat->cmp_seg, &(tdat->rbytes), 0, NULL); + dedupe_index_sz = dedupe_compress(tdat->rctx, tdat->cmp_seg, &(tdat->rbytes), 0, + NULL, tdat->cksum_mt); if (!rctx->valid) { memcpy(tdat->uncompressed_chunk, tdat->cmp_seg, rbytes); tdat->rbytes = rbytes; diff --git a/rabin/rabin_dedup.c b/rabin/rabin_dedup.c index 7612269..8ecdb85 100755 --- a/rabin/rabin_dedup.c +++ b/rabin/rabin_dedup.c @@ -76,6 +76,10 @@ # define SSE_MODE 1 #endif +#if defined(_OPENMP) +#include +#endif + #define DELTA_EXTRA2_PCT(x) ((x) >> 1) #define DELTA_EXTRA_PCT(x) (((x) >> 1) + ((x) >> 3)) #define DELTA_NORMAL_PCT(x) (((x) >> 1) + ((x) >> 2) + ((x) >> 3)) @@ -298,7 +302,8 @@ destroy_dedupe_context(dedupe_context_t *ctx) * from 4K-128K. */ uint32_t -dedupe_compress(dedupe_context_t *ctx, uchar_t *buf, uint64_t *size, uint64_t offset, uint64_t *rabin_pos) +dedupe_compress(dedupe_context_t *ctx, uchar_t *buf, uint64_t *size, uint64_t offset, + uint64_t *rabin_pos, int mt) { uint64_t i, last_offset, j, ary_sz; uint32_t blknum, window_pos; @@ -569,14 +574,20 @@ process_blocks: * have a fast linear scan through the buffer. */ if (ctx->delta_flag) { +#if defined(_OPENMP) +# pragma omp parallel for if (mt) +#endif for (i=0; iblocks[i]->hash = XXH32(buf1+ctx->blocks[i]->offset, - ctx->blocks[i]->length, 0); + ctx->blocks[i]->length, 0); } } else { +#if defined(_OPENMP) +# pragma omp parallel for if (mt) +#endif for (i=0; iblocks[i]->hash = XXH32(buf1+ctx->blocks[i]->offset, - ctx->blocks[i]->length, 0); + ctx->blocks[i]->length, 0); ctx->blocks[i]->similarity_hash = ctx->blocks[i]->hash; } } diff --git a/rabin/rabin_dedup.h b/rabin/rabin_dedup.h index e6d4bbb..1feae91 100644 --- a/rabin/rabin_dedup.h +++ b/rabin/rabin_dedup.h @@ -170,7 +170,7 @@ extern dedupe_context_t *create_dedupe_context(uint64_t chunksize, uint64_t real int file_version, compress_op_t op); extern void destroy_dedupe_context(dedupe_context_t *ctx); extern unsigned int dedupe_compress(dedupe_context_t *ctx, unsigned char *buf, - uint64_t *size, uint64_t offset, uint64_t *rabin_pos); + uint64_t *size, uint64_t offset, uint64_t *rabin_pos, int mt); extern void dedupe_decompress(dedupe_context_t *ctx, uchar_t *buf, uint64_t *size); extern void parse_dedupe_hdr(uchar_t *buf, unsigned int *blknum, uint64_t *dedupe_index_sz, uint64_t *dedupe_data_sz, uint64_t *rabin_index_sz_cmp, diff --git a/utils/utils.c b/utils/utils.c index 795bd2f..a7ab363 100644 --- a/utils/utils.c +++ b/utils/utils.c @@ -239,7 +239,7 @@ Read_Adjusted(int fd, uchar_t *buf, uint64_t count, int64_t *rabin_count, void * * This call does not actually dedupe but finds the last rabin boundary * in the buf. */ - dedupe_compress(rctx, buf, &rc, 0, &rbc); + dedupe_compress(rctx, buf, &rc, 0, &rbc, 0); rcount = rc; *rabin_count = rbc; } else {