Skip to content

Commit

Permalink
Reduce possibility of mistakes.
Browse files Browse the repository at this point in the history
 * Unifies CPU/GPU-shared data structure definitions into a single header
   (nba/framework/datablock_shared.hh)

 * Adds "explicit" specifier to memory pool constructors
  • Loading branch information
achimnol committed Feb 23, 2016
1 parent a7eca05 commit f48ff79
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 46 deletions.
3 changes: 1 addition & 2 deletions elements/ip/IPlookup_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@

#define IGNORED_IP 0xFFffFFffu

/* Compatibility definitions. */
#include <nba/engines/cuda/compat.hh>
#include <nba/framework/datablock_shared.hh>

extern "C" {

Expand Down
3 changes: 1 addition & 2 deletions elements/ipsec/IPsecAES_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
#include <openssl/aes.h>
#include <openssl/md5.h>

/* Compatibility definitions. */
#include <nba/engines/cuda/compat.hh>
#include <nba/framework/datablock_shared.hh>

/* The index is given by the order in get_used_datablocks(). */
#define dbid_enc_payloads_d (0)
Expand Down
3 changes: 1 addition & 2 deletions elements/ipsec/IPsecAuthHMACSHA1_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

#include "IPsecAuthHMACSHA1_kernel.hh"

/* Compatibility definitions. */
#include <nba/engines/cuda/compat.hh>
#include <nba/framework/datablock_shared.hh>

/* The index is given by the order in get_used_datablocks(). */
#define dbid_enc_payloads_d (0)
Expand Down
2 changes: 1 addition & 1 deletion elements/ipv6/LookupIP6Route_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include "util_jhash.h"
#include "util_hash_table.hh"
#include <nba/engines/cuda/compat.hh>
#include <nba/framework/datablock_shared.hh>

using namespace nba;

Expand Down
12 changes: 6 additions & 6 deletions include/nba/engines/cuda/mempool.hh
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ namespace nba {
class CUDAMemoryPool : public MemoryPool<dev_mem_t>
{
public:
CUDAMemoryPool()
explicit CUDAMemoryPool()
: MemoryPool(), base(nullptr)
{ }

CUDAMemoryPool(size_t max_size)
explicit CUDAMemoryPool(size_t max_size)
: MemoryPool(max_size), base(nullptr)
{ }

CUDAMemoryPool(size_t max_size, size_t align)
explicit CUDAMemoryPool(size_t max_size, size_t align)
: MemoryPool(max_size, align), base(nullptr)
{ }

Expand Down Expand Up @@ -63,15 +63,15 @@ private:
class CPUMemoryPool : public MemoryPool<host_mem_t>
{
public:
CPUMemoryPool(int cuda_flags = 0)
explicit CPUMemoryPool(int cuda_flags)
: MemoryPool(), base(nullptr), flags(cuda_flags), use_external(false)
{ }

CPUMemoryPool(size_t max_size, int cuda_flags = 0)
explicit CPUMemoryPool(size_t max_size, int cuda_flags)
: MemoryPool(max_size), base(nullptr), flags(cuda_flags), use_external(false)
{ }

CPUMemoryPool(size_t max_size, size_t align, int cuda_flags = 0)
explicit CPUMemoryPool(size_t max_size, size_t align, int cuda_flags)
: MemoryPool(max_size, align), base(nullptr), flags(cuda_flags), use_external(false)
{ }

Expand Down
30 changes: 1 addition & 29 deletions include/nba/framework/datablock.hh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <nba/framework/config.hh>
#include <nba/framework/computecontext.hh>
#include <nba/core/shiftedint.hh> // should come after cuda headers
#include <nba/framework/datablock_shared.hh>
#include <vector>
#include <string>
#include <tuple>
Expand Down Expand Up @@ -113,35 +114,6 @@ struct datablock_tracker {
dev_mem_t aligned_item_sizes_d;
};

/**
* Datablock batch info struct.
*
* It contains item offset/size information for variable-length datablocks.
*
* NOTE: The alignment of this struct should match with CUDA.
*/
struct datablock_batch_info {
void *buffer_bases_in;
void *buffer_bases_out;
uint32_t item_count_in;
uint32_t item_count_out;
uint16_t *item_sizes_in;
uint16_t *item_sizes_out;
dev_offset_t *item_offsets_in;
dev_offset_t *item_offsets_out;
}; // __cuda_aligned

/**
* Kernel argument spec for datablocks.
*/
struct datablock_kernel_arg {
uint32_t total_item_count_in;
uint32_t total_item_count_out;
uint16_t item_size_in; // for fixed-size cases
uint16_t item_size_out; // for fixed-size cases
struct datablock_batch_info batches[0];
}; // __cuda_aligned


/** Datablock information class.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#ifndef __NBA_ENGINES_CUDA_COMPAT_HH__
#define __NBA_ENGINES_CUDA_COMPAT_HH__
#ifndef __NBA_DATABLOCK_SHARED_HH__
#define __NBA_DATABLOCK_SHARED_HH__

/*
* This header is included by .cu sources.
* We put only relevant data structures here for use in CUDA codes.
* This header is included by both .cc/.cu sources.
* Note that the nvcc should support C++11 (CUDA v6.5 or higher).
*/

Expand Down

0 comments on commit f48ff79

Please sign in to comment.