Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,19 @@ AC_ARG_WITH([protobuf-c-libdir],
AC_ARG_ENABLE([debug],
[AS_HELP_STRING([--enable-debug], [Enable debug print messages. This is a debugging feature which should not be usually enabled])],
[DEBUG_CFLAGS="-DGPUSOCK_DEBUG"])

AC_SUBST(DEBUG_CFLAGS)

AC_ARG_ENABLE([timers],
[AS_HELP_STRING([--enable-timers], [Enable performance timers])],
[timers=yes])

AS_IF([test "x$timers" == xyes],
[AC_CHECK_LIB([rt], [clock_gettime],
[AC_SUBST([TIMERS_LIBS], ["-lrt"])
AC_SUBST([TIMERS_CFLAGS], ["-DTIMERS_ENABLED"])
])
])

#AX_LIB_PROTOBUF_C([0.14])

AC_CHECK_LIB([protobuf-c], [main], [], [AC_MSG_ERROR([cannot find protobuf library])])
Expand All @@ -35,6 +45,9 @@ AC_ARG_WITH([protoc-c],
[PROTOC_C='protoc-c'])
AC_SUBST([PROTOC_C])

AC_CHECK_LIB(pthread, pthread_create, [PTHREAD_LIBS+=-lpthread])
AC_SUBST([PTHREAD_LIBS])

AC_PROG_CXX

AM_SILENT_RULES([no])
Expand Down
12 changes: 5 additions & 7 deletions src/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
bin_PROGRAMS = server libcudawrapper.so #test-cuda test-client


CYCLES_PER_SEC = `cat /proc/cpuinfo |grep cpu\ MHz | head -1 | cut -d\: -f2 | awk '{ print $$1 * 1000 }'`

AM_CFLAGS = -I$(PROTOBUF_C_CFLAGS) -L$(PROTOBUF_C_LIBDIR) -L$(CUDA) -I@builddir@ -I/usr/include/google -L$(CUDA_INSTALL_PATH)/lib -I$(CUDA_INSTALL_PATH)/include -DCYCLES_PER_SEC=$(CYCLES_PER_SEC) $(DEBUG_CFLAGS)
AM_CFLAGS = -I$(PROTOBUF_C_CFLAGS) -L$(PROTOBUF_C_LIBDIR) -L$(CUDA) -I@builddir@ -I/usr/include/google -L$(CUDA_INSTALL_PATH)/lib -I$(CUDA_INSTALL_PATH)/include $(TIMERS_CFLAGS) $(DEBUG_CFLAGS)


BUILT_SOURCES = @srcdir@/common.pb-c.c @srcdir@/common.pb-c.h

server_SOURCES = server.c process.c process.h common.h common.c protocol.c protocol.h list.h cuda_errors.h
server_SOURCES = server.c process.c process.h common.h common.c protocol.c protocol.h list.h cuda_errors.h timer.h
server_SOURCES += common.pb-c.c common.pb-c.h

libcudawrapper_so_CFLAGS = -fPIC -shared $(DEBUG_CFLAGS)
libcudawrapper_so_CFLAGS = -fPIC -shared $(TIMERS_CFLAGS) $(DEBUG_CFLAGS)
libcudawrapper_so_CFLAGS += -L$(CUDA_INSTALL_PATH)/lib -I$(CUDA_INSTALL_PATH)/include
libcudawrapper_so_SOURCES = libcudawrapper.c process.c process.h common.h common.c protocol.c protocol.h list.h cuda_errors.h client.h client.c
libcudawrapper_so_SOURCES += common.pb-c.c common.pb-c.h
Expand All @@ -27,8 +25,8 @@ common.pb-c.h: @srcdir@/common.pb-c.c

CLEANFILES = @builddir@/common.pb-c.c @builddir@/common.pb-c.h

server_LDADD = $(PROTOBUF_C_LIBS) $(CUDA_LIBS) -lcuda
libcudawrapper_so_LDADD = $(PROTOBUF_C_LIBS) $(CUDA_LIBS) -lcuda -ldl
server_LDADD = $(PROTOBUF_C_LIBS) $(CUDA_LIBS) -lcuda $(PTHREAD_LIBS) $(TIMERS_LIBS)
libcudawrapper_so_LDADD = $(PROTOBUF_C_LIBS) $(CUDA_LIBS) -lcuda -ldl $(TIMERS_LIBS)

EXTRA_DIST = common.proto

Expand Down
14 changes: 14 additions & 0 deletions src/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "common.pb-c.h"
#include "protocol.h"
#include "process.h"
#include "timer.h"

int init_client(const char *s_ip, const char *s_port, struct addrinfo *s_addr) {
int socket_fd, ret;
Expand Down Expand Up @@ -100,6 +101,9 @@ int64_t get_cuda_cmd_result(void **result, int sock_fd) {
void *buffer=NULL, *payload=NULL, *dec_msg=NULL;
int res_code;

gs_timer tm;
TIMER_RESET(&tm);
TIMER_START(&tm);
gdprintf("Waiting for response:\n");
msg_length = receive_message(&buffer, sock_fd);
if (msg_length > 0) {
Expand Down Expand Up @@ -131,6 +135,9 @@ int64_t get_cuda_cmd_result(void **result, int sock_fd) {
if (buffer != NULL)
free(buffer);

TIMER_STOP(&tm);
gdprintf("\nClient Receive: %lf\n", TIMER_TO_SEC(TIMER_TOTAL(&tm)));

return res_code;
}

Expand Down Expand Up @@ -173,6 +180,10 @@ int send_cuda_cmd(int sock_fd, var **args, size_t arg_count, int type) {
void *buffer = NULL, *payload = NULL;
size_t buf_size;

gs_timer tm;
TIMER_RESET(&tm);
TIMER_START(&tm);

gdprintf("Sendind CUDA cmd...\n");
pack_cuda_cmd(&payload, args, arg_count, type);

Expand All @@ -184,6 +195,9 @@ int send_cuda_cmd(int sock_fd, var **args, size_t arg_count, int type) {

free(buffer);

TIMER_STOP(&tm);
gdprintf("\nClient Send: %lf\n", TIMER_TO_SEC(TIMER_TOTAL(&tm)));

return 0;
}

Expand Down
1 change: 0 additions & 1 deletion src/libcudawrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "common.pb-c.h"
#include "client.h"


//TODO: assert stored results' size fits...

static params c_params;
Expand Down
Loading