Skip to content

Commit

Permalink
review edits
Browse files Browse the repository at this point in the history
  • Loading branch information
CoderHam committed Aug 26, 2019
1 parent 4a2a20b commit fa3a012
Show file tree
Hide file tree
Showing 11 changed files with 215 additions and 236 deletions.
15 changes: 11 additions & 4 deletions src/clients/c++/simple_shm_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,17 @@ CreateSharedMemoryRegion(std::string shm_key, size_t batch_byte_size)
// get shared memory region descriptor
int shm_fd = shm_open(shm_key.c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
if (shm_fd == -1) {
std::cerr << "error: unable to get shared memory descriptor";
std::cerr << "error: unable to get shared memory descriptor for "
"shared-memory key '" +
shm_key + "'";
exit(1);
}
// extend shared memory object as by default it's initialized with size 0
int res = ftruncate(shm_fd, batch_byte_size);
if (res == -1) {
std::cerr << "error: unable to initialize the size";
std::cerr << "error: unable to initialize shared-memory key '" + shm_key +
"' to requested size " + std::to_string(batch_byte_size) +
" bytes";
exit(1);
}
return shm_fd;
Expand All @@ -93,7 +97,9 @@ MapSharedMemory(int shm_fd, size_t offset, size_t batch_byte_size)
void* shm_addr =
mmap(NULL, batch_byte_size, PROT_WRITE, MAP_SHARED, shm_fd, offset);
if (shm_addr == MAP_FAILED) {
std::cerr << "error: unable to process address space";
std::cerr << "error: unable to process address space or shared-memory "
"descriptor: " +
std::to_string(shm_fd);
exit(1);
}
return shm_addr;
Expand All @@ -104,7 +110,8 @@ UnlinkSharedMemoryRegion(std::string shm_key)
{
int shm_fd = shm_unlink(shm_key.c_str());
if (shm_fd == -1) {
std::cerr << "error: unable to unlink shared memory for " << shm_key;
std::cerr << "error: unable to unlink shared memory for key '" + shm_key +
"'";
exit(1);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/clients/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ target_link_libraries(
)

#
# libcshmwrap.so
# libcshm.so
#
add_library(cshmwrap SHARED shared_memory_wrapper.cc)
add_library(cshm SHARED shared_memory/shared_memory.cc)
target_link_libraries(
cshmwrap
cshm
request
rt
)
Expand Down
2 changes: 1 addition & 1 deletion src/clients/python/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved.
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
Expand Down
4 changes: 1 addition & 3 deletions src/clients/python/build_wheel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,13 @@ function main() {
"${WHLDIR}/tensorrtserver/api/."
cp ../c++/librequest.so \
"${WHLDIR}/tensorrtserver/api/."
cp libcshmwrap.so \
cp libcshm.so \
"${WHLDIR}/tensorrtserver/shared_memory/."
else
cp Release/crequest.dll \
"${WHLDIR}/tensorrtserver/api/."
cp ../c++/Release/request.dll \
"${WHLDIR}/tensorrtserver/api/."
cp Release/cshmwrap.dll \
"${WHLDIR}/tensorrtserver/shared_memory/."
fi

cp __init__.py \
Expand Down
6 changes: 3 additions & 3 deletions src/clients/python/crequest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <iostream>
#include "src/clients/c++/request_grpc.h"
#include "src/clients/c++/request_http.h"
#include "src/clients/python/shared_memory_handle.h"
#include "src/clients/python/shared_memory/shared_memory_handle.h"

namespace ni = nvidia::inferenceserver;
namespace nic = nvidia::inferenceserver::client;
Expand Down Expand Up @@ -402,8 +402,8 @@ nic::Error*
GetSharedMemoryHandleInfo(
void* shm_handle, void** shm_addr, const char** shm_key, int* shm_fd)
{
shared_memory_handle* handle =
reinterpret_cast<shared_memory_handle*>(shm_handle);
SharedMemoryHandle* handle =
reinterpret_cast<SharedMemoryHandle*>(shm_handle);
*shm_addr = handle->base_addr_;
*shm_key = handle->shm_key_.c_str();
*shm_fd = handle->shm_fd_;
Expand Down
4 changes: 2 additions & 2 deletions src/clients/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ def get_tag(self):
bdist_wheel = None

if os.name == 'nt':
platform_package_data = [ 'crequest.dll', 'request.dll', 'libcshmwrap.dll', ]
platform_package_data = [ 'crequest.dll', 'request.dll']
else:
platform_package_data = [ 'libcrequest.so', 'librequest.so', 'libcshmwrap.so', ]
platform_package_data = [ 'libcrequest.so', 'librequest.so', 'libcshm.so' ]

setup(
name='tensorrtserver',
Expand Down
Loading

0 comments on commit fa3a012

Please sign in to comment.