Skip to content

Commit

Permalink
Fix signed and unsigned comparison warnings (#149)
Browse files Browse the repository at this point in the history
Signed-off-by: Zhiting Zhu <zhitingz@cs.utexas.edu>
  • Loading branch information
photoszzt authored Jun 5, 2021
1 parent 045b410 commit 244d47a
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 21 deletions.
10 changes: 5 additions & 5 deletions cava/samples/onnxruntime/onnx_opt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1895,7 +1895,7 @@ cuEventCreate(CUevent *phEvent, unsigned int Flags)
if (g_queue_is_empty(cu_event_pool)) {
size_t count = DESCRITPOR_POOL_SIZE;
CUevent *desc = (CUevent *)malloc(sizeof(CUevent) * count);
int i;
size_t i;
res = __pool_cuEventCreate(desc, count);

if (res == CUDA_SUCCESS) {
Expand Down Expand Up @@ -5997,7 +5997,7 @@ cudnnCreateConvolutionDescriptor(cudnnConvolutionDescriptor_t *convDesc)
size_t count = DESCRITPOR_POOL_SIZE;
cudnnConvolutionDescriptor_t *desc = (cudnnConvolutionDescriptor_t *)
malloc(sizeof(cudnnConvolutionDescriptor_t) * count);
int i;
size_t i;
res = __pool_cudnnCreateConvolutionDescriptor(desc, count);

if (res == CUDNN_STATUS_SUCCESS) {
Expand All @@ -6022,7 +6022,7 @@ cudnnCreateFilterDescriptor(cudnnFilterDescriptor_t *filterDesc)
size_t count = DESCRITPOR_POOL_SIZE;
cudnnFilterDescriptor_t *desc = (cudnnFilterDescriptor_t *)
malloc(sizeof(cudnnFilterDescriptor_t) * count);
int i;
size_t i;
res = __pool_cudnnCreateFilterDescriptor(desc, count);

if (res == CUDNN_STATUS_SUCCESS) {
Expand All @@ -6047,7 +6047,7 @@ cudnnCreatePoolingDescriptor(cudnnPoolingDescriptor_t *poolingDesc)
size_t count = DESCRITPOR_POOL_SIZE;
cudnnPoolingDescriptor_t *desc = (cudnnPoolingDescriptor_t *)
malloc(sizeof(cudnnPoolingDescriptor_t) * count);
int i;
size_t i = 0;
res = __pool_cudnnCreatePoolingDescriptor(desc, count);

if (res == CUDNN_STATUS_SUCCESS) {
Expand All @@ -6072,7 +6072,7 @@ cudnnCreateTensorDescriptor(cudnnTensorDescriptor_t *tensorDesc)
size_t count = DESCRITPOR_POOL_SIZE;
cudnnTensorDescriptor_t *desc = (cudnnTensorDescriptor_t *)
malloc(sizeof(cudnnTensorDescriptor_t) * count);
int i;
size_t i;
res = __pool_cudnnCreateTensorDescriptor(desc, count);

if (res == CUDNN_STATUS_SUCCESS) {
Expand Down
2 changes: 1 addition & 1 deletion common/cmd_channel_record.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ ssize_t command_channel_log_transfer_command(struct command_channel_log *c, cons
void command_channel_log_update_flags(struct command_channel_log *chan, ssize_t offset, uint32_t flags) {
assert(offset >= 0);
off_t r = lseek(chan->fd, offset + sizeof(size_t), SEEK_SET);
assert(r == offset + sizeof(size_t));
assert(gsl::narrow_cast<unsigned long>(r) == offset + sizeof(size_t));
(void)r;
ssize_t ret = write(chan->fd, &flags, sizeof(flags));
if (ret == -1) {
Expand Down
4 changes: 3 additions & 1 deletion common/extensions/cudart_10.1_utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ cudaError_t __helper_launch_kernel(struct fatbin_function *func, const void *hos
void **args, size_t sharedMem, cudaStream_t stream) {
cudaError_t ret = (cudaError_t)CUDA_ERROR_PROFILER_ALREADY_STOPPED;

if (func == NULL) return (cudaError_t)CUDA_ERROR_INVALID_PTX;
if (func == NULL) {
return (cudaError_t)CUDA_ERROR_INVALID_PTX;
}

if (func->hostfunc != hostFun) {
LOG_ERROR << "search host func " << hostFun << " -> stored " << (void *)func->hostfunc << " (device func "
Expand Down
2 changes: 2 additions & 0 deletions common/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#ifdef __cplusplus
#include <plog/Log.h>

#include <memory>

#include "declaration.h"

#define PLOG_CAPTURE_FILE
Expand Down
4 changes: 3 additions & 1 deletion common/shadow_thread_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include <plog/Log.h>
#include <stdio.h>

#include <gsl/gsl>

#include "common/cmd_handler.hpp"
#include "common/endpoint_lib.hpp"
#include "common/linkage.h"
Expand Down Expand Up @@ -116,7 +118,7 @@ int shadow_thread_handle_single_command(struct shadow_thread_pool_t *pool) {
return 1;
}

assert(cmd->thread_id == t->ava_id);
assert(gsl::narrow_cast<uintptr_t>(cmd->thread_id) == t->ava_id);
// TODO: checks MSG_SHUTDOWN messages/channel close from the other side.

handle_command_and_notify(chan, cmd);
Expand Down
6 changes: 4 additions & 2 deletions guestlib/extensions/cmd_batching.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <stdlib.h>
#include <string.h>

#include <gsl/gsl>

#include "common/cmd_channel.hpp"
#include "common/endpoint_lib.hpp"
#include "common/linkage.h"
Expand Down Expand Up @@ -46,7 +48,7 @@ static void batch_emit(GAsyncQueue *active_cmds) {
offset += cmd->command_size + cmd->region_size;
free(cmd);
}
assert(offset == __total_buffer_size);
assert(gsl::narrow_cast<size_t>(offset) == __total_buffer_size);
}

/* __do_batch_emit is generated by AvA. */
Expand All @@ -68,7 +70,7 @@ static void batch_emit(GAsyncQueue *active_cmds) {
*/
EXPORTED_WEAKLY void batch_insert_command(struct command_batch *cmd_batch, struct command_base *cmd,
struct command_channel *chan, int is_async) {
struct command_wrapper *wrap = g_malloc(sizeof(struct command_wrapper));
struct command_wrapper *wrap = reinterpret_cast<struct command_wrapper *>(g_malloc(sizeof(struct command_wrapper)));
wrap->cmd = cmd;
wrap->chan = chan;
wrap->is_async = is_async;
Expand Down
4 changes: 3 additions & 1 deletion worker/extensions/cmd_batching.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "common/extensions/cmd_batching.h"

#include <gsl/gsl>

#include "common/linkage.h"

struct command_batch *nw_global_cmd_batch = NULL; // always NULL
Expand All @@ -20,7 +22,7 @@ EXPORTED_WEAKLY void __do_batch_execute(void *command_buffer, size_t total_buffe
off_t offset = 0;
struct command_base *cmd;

while (offset < total_buffer_size) {
while (gsl::narrow_cast<size_t>(offset) < total_buffer_size) {
cmd = (struct command_base *)(command_buffer + offset);
offset += cmd->command_size + cmd->region_size;
__handle_command_cudart_opt_single(NULL, NULL, NULL, cmd);
Expand Down
16 changes: 8 additions & 8 deletions worker/extensions/cudnn_optimization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void worker_cudnn_opt_init(void) {
}

cudnnStatus_t __pool_cudnnCreateConvolutionDescriptor(cudnnConvolutionDescriptor_t *convDesc, size_t count) {
int i;
size_t i;
cudnnConvolutionDescriptor_t *desc;
cudnnStatus_t res = CUDNN_STATUS_SUCCESS;

Expand All @@ -63,7 +63,7 @@ cudnnStatus_t __pool_cudnnCreateConvolutionDescriptor(cudnnConvolutionDescriptor
}

cudnnStatus_t __pool_cudnnDestroyConvolutionDescriptor(cudnnConvolutionDescriptor_t *convDesc, size_t count) {
int i;
size_t i;
cudnnStatus_t res;

for (i = 0; i < count; i++) {
Expand All @@ -75,7 +75,7 @@ cudnnStatus_t __pool_cudnnDestroyConvolutionDescriptor(cudnnConvolutionDescripto
}

cudnnStatus_t __pool_cudnnCreatePoolingDescriptor(cudnnPoolingDescriptor_t *poolingDesc, size_t count) {
int i;
size_t i;
cudnnPoolingDescriptor_t *desc;
cudnnStatus_t res = CUDNN_STATUS_SUCCESS;

Expand All @@ -89,7 +89,7 @@ cudnnStatus_t __pool_cudnnCreatePoolingDescriptor(cudnnPoolingDescriptor_t *pool
}

cudnnStatus_t __pool_cudnnDestroyPoolingDescriptor(cudnnPoolingDescriptor_t *poolingDesc, size_t count) {
int i;
size_t i;
cudnnStatus_t res;

for (i = 0; i < count; i++) {
Expand All @@ -101,7 +101,7 @@ cudnnStatus_t __pool_cudnnDestroyPoolingDescriptor(cudnnPoolingDescriptor_t *poo
}

cudnnStatus_t __pool_cudnnCreateTensorDescriptor(cudnnTensorDescriptor_t *tensorDesc, size_t count) {
int i;
size_t i;
cudnnTensorDescriptor_t *desc;
cudnnStatus_t res = CUDNN_STATUS_SUCCESS;

Expand All @@ -115,7 +115,7 @@ cudnnStatus_t __pool_cudnnCreateTensorDescriptor(cudnnTensorDescriptor_t *tensor
}

cudnnStatus_t __pool_cudnnDestroyTensorDescriptor(cudnnTensorDescriptor_t *tensorDesc, size_t count) {
int i;
size_t i;
cudnnStatus_t res;

for (i = 0; i < count; i++) {
Expand All @@ -127,7 +127,7 @@ cudnnStatus_t __pool_cudnnDestroyTensorDescriptor(cudnnTensorDescriptor_t *tenso
}

cudnnStatus_t __pool_cudnnCreateFilterDescriptor(cudnnFilterDescriptor_t *filterDesc, size_t count) {
int i;
size_t i;
cudnnFilterDescriptor_t *desc;
cudnnStatus_t res = CUDNN_STATUS_SUCCESS;

Expand All @@ -141,7 +141,7 @@ cudnnStatus_t __pool_cudnnCreateFilterDescriptor(cudnnFilterDescriptor_t *filter
}

cudnnStatus_t __pool_cudnnDestroyFilterDescriptor(cudnnFilterDescriptor_t *filterDesc, size_t count) {
int i;
size_t i;
cudnnStatus_t res;

for (i = 0; i < count; i++) {
Expand Down
4 changes: 2 additions & 2 deletions worker/extensions/tf_optimization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void guestlib_tf_opt_fini(void) {}
void worker_tf_opt_init(void) { worker_cudnn_opt_init(); }

CUresult __pool_cuEventCreate(CUevent *phEvent, size_t count) {
int i;
size_t i;
CUevent *desc;
CUresult res = CUDA_SUCCESS;

Expand All @@ -31,7 +31,7 @@ CUresult __pool_cuEventCreate(CUevent *phEvent, size_t count) {
}

CUresult __pool_cuEventDestroy(CUevent *hEvent, size_t count) {
int i;
size_t i;
CUresult res;

for (i = 0; i < count; i++) {
Expand Down

0 comments on commit 244d47a

Please sign in to comment.