GPU-Accelerated Cuckoo Filter
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
cuckoogpu::FilterIPCClient< Config > Class Template Reference

Client implementation for the IPC Cuckoo Filter. More...

Public Types

using T = typename Config::KeyType
 

Public Member Functions

 FilterIPCClient (const std::string &name)
 Constructs a new FilterIPCClient.
 
 ~FilterIPCClient ()
 Destroys the FilterIPCClient.
 
size_t insertMany (const T *d_keys, size_t count)
 Inserts multiple keys into the filter.
 
void containsMany (const T *d_keys, size_t count, bool *d_output)
 Checks for existence of multiple keys.
 
size_t deleteMany (const T *d_keys, size_t count, bool *d_output=nullptr)
 Deletes multiple keys from the filter.
 
void clear ()
 Clears the filter.
 
void requestShutdown ()
 Requests the server to shut down.
 
size_t insertMany (const thrust::device_vector< T > &d_keys)
 Inserts keys from a Thrust device vector.
 
void containsMany (const thrust::device_vector< T > &d_keys, thrust::device_vector< bool > &d_output)
 Checks for existence of keys in a Thrust device vector.
 
void containsMany (const thrust::device_vector< T > &d_keys, thrust::device_vector< uint8_t > &d_output)
 Checks for existence of keys in a Thrust device vector (uint8_t output).
 
size_t deleteMany (const thrust::device_vector< T > &d_keys, thrust::device_vector< bool > &d_output)
 Deletes keys in a Thrust device vector.
 
size_t deleteMany (const thrust::device_vector< T > &d_keys, thrust::device_vector< uint8_t > &d_output)
 Deletes keys in a Thrust device vector (uint8_t output).
 
size_t deleteMany (const thrust::device_vector< T > &d_keys)
 Deletes keys in a Thrust device vector without outputting results.
 

Detailed Description

template<typename Config>
class cuckoogpu::FilterIPCClient< Config >

Client implementation for the IPC Cuckoo Filter.

This class connects to an existing shared memory segment created by a server and allows submitting filter operations. It handles the details of mapping memory handles for CUDA IPC.

Template Parameters
ConfigThe configuration structure for the Cuckoo Filter.

Definition at line 459 of file CuckooFilterIPC.cuh.

Member Typedef Documentation

◆ T

template<typename Config >
using cuckoogpu::FilterIPCClient< Config >::T = typename Config::KeyType

Definition at line 467 of file CuckooFilterIPC.cuh.

Constructor & Destructor Documentation

◆ FilterIPCClient()

template<typename Config >
cuckoogpu::FilterIPCClient< Config >::FilterIPCClient ( const std::string &  name)
inlineexplicit

Constructs a new FilterIPCClient.

Connects to the shared memory segment.

Parameters
nameName of the shared memory segment to connect to.

Definition at line 476 of file CuckooFilterIPC.cuh.

477 : shmName("/cuckoo_filter_" + name), nextRequestId(0) {
478 shmFd = shm_open(shmName.c_str(), O_RDWR, 0666);
479 if (shmFd == -1) {
480 throw std::runtime_error("Failed to open shared memory, is the server running?");
481 }
482
483 queue = static_cast<SharedQueue*>(
484 mmap(nullptr, sizeof(SharedQueue), PROT_READ | PROT_WRITE, MAP_SHARED, shmFd, 0)
485 );
486
487 if (queue == MAP_FAILED) {
488 close(shmFd);
489 throw std::runtime_error("Failed to map shared memory");
490 }
491
492 if (!queue->initialised.load(std::memory_order_acquire)) {
493 munmap(queue, sizeof(SharedQueue));
494 close(shmFd);
495 throw std::runtime_error("Ring buffer not initialised, server may not be ready");
496 }
497 }
std::atomic< bool > initialised
Whether the queue has been initialised.

◆ ~FilterIPCClient()

template<typename Config >
cuckoogpu::FilterIPCClient< Config >::~FilterIPCClient ( )
inline

Destroys the FilterIPCClient.

Unmaps the shared memory.

Definition at line 504 of file CuckooFilterIPC.cuh.

504 {
505 if (queue != MAP_FAILED) {
506 munmap(queue, sizeof(SharedQueue));
507 }
508 if (shmFd != -1) {
509 close(shmFd);
510 }
511 }

Member Function Documentation

◆ clear()

template<typename Config >
void cuckoogpu::FilterIPCClient< Config >::clear ( )
inline

Clears the filter.

Definition at line 550 of file CuckooFilterIPC.cuh.

550 {
551 submitRequest(RequestType::CLEAR, nullptr, 0, nullptr);
552 }

◆ containsMany() [1/3]

template<typename Config >
void cuckoogpu::FilterIPCClient< Config >::containsMany ( const T d_keys,
size_t  count,
bool *  d_output 
)
inline

Checks for existence of multiple keys.

Parameters
d_keysPointer to device memory containing keys.
countNumber of keys to check.
d_outputPointer to device memory to store results (true/false).

Definition at line 531 of file CuckooFilterIPC.cuh.

531 {
532 submitRequest(RequestType::CONTAINS, d_keys, count, d_output);
533 }
Here is the caller graph for this function:

◆ containsMany() [2/3]

template<typename Config >
void cuckoogpu::FilterIPCClient< Config >::containsMany ( const thrust::device_vector< T > &  d_keys,
thrust::device_vector< bool > &  d_output 
)
inline

Checks for existence of keys in a Thrust device vector.

Parameters
d_keysVector of keys to check.
d_outputVector to store results (bool). Resized if necessary.

Definition at line 593 of file CuckooFilterIPC.cuh.

593 {
594 if (d_output.size() != d_keys.size()) {
595 d_output.resize(d_keys.size());
596 }
598 thrust::raw_pointer_cast(d_keys.data()),
599 d_keys.size(),
600 thrust::raw_pointer_cast(d_output.data())
601 );
602 }
void containsMany(const T *d_keys, size_t count, bool *d_output)
Checks for existence of multiple keys.
Here is the call graph for this function:

◆ containsMany() [3/3]

template<typename Config >
void cuckoogpu::FilterIPCClient< Config >::containsMany ( const thrust::device_vector< T > &  d_keys,
thrust::device_vector< uint8_t > &  d_output 
)
inline

Checks for existence of keys in a Thrust device vector (uint8_t output).

Parameters
d_keysVector of keys to check.
d_outputVector to store results (uint8_t). Resized if necessary.

Definition at line 610 of file CuckooFilterIPC.cuh.

610 {
611 if (d_output.size() != d_keys.size()) {
612 d_output.resize(d_keys.size());
613 }
615 thrust::raw_pointer_cast(d_keys.data()),
616 d_keys.size(),
617 reinterpret_cast<bool*>(thrust::raw_pointer_cast(d_output.data()))
618 );
619 }
Here is the call graph for this function:

◆ deleteMany() [1/4]

template<typename Config >
size_t cuckoogpu::FilterIPCClient< Config >::deleteMany ( const T d_keys,
size_t  count,
bool *  d_output = nullptr 
)
inline

Deletes multiple keys from the filter.

Parameters
d_keysPointer to device memory containing keys.
countNumber of keys to delete.
d_outputOptional pointer to device memory to store results (true if deleted).
Returns
size_t Total number of occupied slots after deletion.

Definition at line 543 of file CuckooFilterIPC.cuh.

543 {
544 return submitRequest(RequestType::DELETE, d_keys, count, d_output);
545 }
Here is the caller graph for this function:

◆ deleteMany() [2/4]

template<typename Config >
size_t cuckoogpu::FilterIPCClient< Config >::deleteMany ( const thrust::device_vector< T > &  d_keys)
inline

Deletes keys in a Thrust device vector without outputting results.

Parameters
d_keysVector of keys to delete.
Returns
size_t Total number of occupied slots.

Definition at line 662 of file CuckooFilterIPC.cuh.

662 {
663 return deleteMany(thrust::raw_pointer_cast(d_keys.data()), d_keys.size(), nullptr);
664 }
size_t deleteMany(const T *d_keys, size_t count, bool *d_output=nullptr)
Deletes multiple keys from the filter.
Here is the call graph for this function:

◆ deleteMany() [3/4]

template<typename Config >
size_t cuckoogpu::FilterIPCClient< Config >::deleteMany ( const thrust::device_vector< T > &  d_keys,
thrust::device_vector< bool > &  d_output 
)
inline

Deletes keys in a Thrust device vector.

Parameters
d_keysVector of keys to delete.
d_outputVector to store results (bool). Resized if necessary.
Returns
size_t Total number of occupied slots.

Definition at line 628 of file CuckooFilterIPC.cuh.

628 {
629 if (d_output.size() != d_keys.size()) {
630 d_output.resize(d_keys.size());
631 }
632 return deleteMany(
633 thrust::raw_pointer_cast(d_keys.data()),
634 d_keys.size(),
635 thrust::raw_pointer_cast(d_output.data())
636 );
637 }
Here is the call graph for this function:

◆ deleteMany() [4/4]

template<typename Config >
size_t cuckoogpu::FilterIPCClient< Config >::deleteMany ( const thrust::device_vector< T > &  d_keys,
thrust::device_vector< uint8_t > &  d_output 
)
inline

Deletes keys in a Thrust device vector (uint8_t output).

Parameters
d_keysVector of keys to delete.
d_outputVector to store results (uint8_t). Resized if necessary.
Returns
size_t Total number of occupied slots.

Definition at line 646 of file CuckooFilterIPC.cuh.

646 {
647 if (d_output.size() != d_keys.size()) {
648 d_output.resize(d_keys.size());
649 }
650 return deleteMany(
651 thrust::raw_pointer_cast(d_keys.data()),
652 d_keys.size(),
653 reinterpret_cast<bool*>(thrust::raw_pointer_cast(d_output.data()))
654 );
655 }
Here is the call graph for this function:

◆ insertMany() [1/2]

template<typename Config >
size_t cuckoogpu::FilterIPCClient< Config >::insertMany ( const T d_keys,
size_t  count 
)
inline

Inserts multiple keys into the filter.

Parameters
d_keysPointer to device memory containing keys.
countNumber of keys to insert.
Returns
size_t Total number of occupied slots after insertion.

Definition at line 520 of file CuckooFilterIPC.cuh.

520 {
521 return submitRequest(RequestType::INSERT, d_keys, count, nullptr);
522 }
Here is the caller graph for this function:

◆ insertMany() [2/2]

template<typename Config >
size_t cuckoogpu::FilterIPCClient< Config >::insertMany ( const thrust::device_vector< T > &  d_keys)
inline

Inserts keys from a Thrust device vector.

Parameters
d_keysVector of keys to insert.
Returns
size_t Total number of occupied slots.

Definition at line 583 of file CuckooFilterIPC.cuh.

583 {
584 return insertMany(thrust::raw_pointer_cast(d_keys.data()), d_keys.size());
585 }
size_t insertMany(const T *d_keys, size_t count)
Inserts multiple keys into the filter.
Here is the call graph for this function:

◆ requestShutdown()

template<typename Config >
void cuckoogpu::FilterIPCClient< Config >::requestShutdown ( )
inline

Requests the server to shut down.

Definition at line 557 of file CuckooFilterIPC.cuh.

557 {
558 if (queue->isShuttingDown()) {
559 return;
560 }
561
562 queue->initiateShutdown();
563
564 FilterRequest* req = queue->enqueue();
565 if (req) {
567 req->completed.store(false, std::memory_order_release);
568 req->cancelled.store(false, std::memory_order_release);
569
570 queue->signalEnqueued();
571
572 while (!req->completed.load(std::memory_order_acquire)) {
573 std::this_thread::yield();
574 }
575 }
576 }
RequestType type
Type of request.
void initiateShutdown()
Initiates the shutdown process for the queue.
FilterRequest * enqueue()
Attempts to acquire a slot in the queue for a new request.
void signalEnqueued()
Signals that a new request has been enqueued and is ready for processing.
bool isShuttingDown() const
Checks if the queue is in shutdown mode.
Here is the call graph for this function:

The documentation for this class was generated from the following file: