Skip to content

Commit

Permalink
Perftest: Fix payload modification length bug
Browse files Browse the repository at this point in the history
This commit fix an implementation bug .
currently perftest get the payload length using strlen.
strlen returns the length of null-terminated string, since the
payload contains 0 values, the returned length is incorrect.

Signed-off-by: Shmuel Shaul <[email protected]>
  • Loading branch information
sshaulnv authored and HassanKhadour committed Mar 21, 2023
1 parent 89029a9 commit a416f72
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/perftest_parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@ struct perftest_parameters {
int has_payload_modification;
char* payload_file_path;
char* payload_content;
int payload_length;
#ifdef HAVE_CUDA
int use_cuda;
int cuda_device_id;
Expand Down
6 changes: 3 additions & 3 deletions src/perftest_resources.c
Original file line number Diff line number Diff line change
Expand Up @@ -1946,9 +1946,8 @@ int create_single_mr(struct pingpong_context *ctx, struct perftest_parameters *u
} else {
if (user_param->has_payload_modification) {
int i;
int payload_len = strlen(user_param->payload_content);
for (i = 0; i < ctx->buff_size; i++) {
((char*)ctx->buf[qp_index])[i] = user_param->payload_content[i % payload_len];
((char*)ctx->buf[qp_index])[i] = user_param->payload_content[i % user_param->payload_length];
}
} else {
random_data(ctx->buf[qp_index], ctx->buff_size);
Expand Down Expand Up @@ -2025,6 +2024,7 @@ static int create_payload(struct perftest_parameters *user_param)
return 1;
}
user_param->payload_content[counter] = (char) strtol(current_byte_chars, NULL, 16);

counter++;
if (counter == user_param->size)
break;
Expand All @@ -2033,7 +2033,7 @@ static int create_payload(struct perftest_parameters *user_param)
} while (token != NULL && counter < user_param->size);

user_param->payload_content[counter] = '\0';

user_param->payload_length = counter;
free(file_content);
fclose(fptr);

Expand Down

0 comments on commit a416f72

Please sign in to comment.