Skip to content
This repository was archived by the owner on Mar 22, 2023. It is now read-only.

Commit 4808295

Browse files
Merge pull request #1087 from igchor/queue_arbitrary_size
mpsc_queue: extend queue to support arbitrary sized values
2 parents 7416299 + 26fdc8e commit 4808295

21 files changed

Lines changed: 1610 additions & 358 deletions

.github/workflows/gha.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ jobs:
9191
windows:
9292
name: Windows
9393
runs-on: windows-latest
94+
9495
env:
9596
platform: x64
9697
VCPKG_DEFAULT_TRIPLET: x64-windows
@@ -154,7 +155,6 @@ jobs:
154155
-DTESTS_TBB=ON
155156
-DDEVELOPER_MODE=ON
156157
-DCXX_STANDARD="${{ matrix.CXX_STANDARD }}"
157-
-DTEST_MPSC_QUEUE=OFF
158158

159159
- name: Build
160160
run: msbuild build/ALL_BUILD.vcxproj /property:Configuration=${{ matrix.BUILD_TYPE }} /verbosity:minimal /m

include/libpmemobj++/detail/common.hpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,14 @@ namespace experimental
150150
namespace detail
151151
{
152152

153+
#if defined(__x86_64) || defined(_M_X64) || defined(__aarch64__)
154+
static constexpr size_t CACHELINE_SIZE = 64ULL;
155+
#elif defined(__PPC64__)
156+
static constexpr size_t CACHELINE_SIZE = 128ULL;
157+
#else
158+
#error unable to recognize architecture at compile time
159+
#endif
160+
153161
/*
154162
* Conditionally add 'count' objects to a transaction.
155163
*
@@ -303,6 +311,18 @@ mssb_index64(uint64_t value)
303311

304312
#endif
305313

314+
static constexpr size_t
315+
align_up(size_t size, size_t align)
316+
{
317+
return ((size) + (align)-1) & ~((align)-1);
318+
}
319+
320+
static constexpr size_t
321+
align_down(size_t size, size_t align)
322+
{
323+
return (size) & ~((align)-1);
324+
}
325+
306326
} /* namespace detail */
307327

308328
} /* namespace pmem */

include/libpmemobj++/detail/ringbuf.hpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,22 @@ struct ringbuf_t {
115115
space = length;
116116
end = RBUF_OFF_MAX;
117117
nworkers = max_workers;
118+
119+
/* Helgrind/Drd does not understand std::atomic */
120+
#if LIBPMEMOBJ_CPP_VG_HELGRIND_ENABLED
121+
VALGRIND_HG_DISABLE_CHECKING(&next, sizeof(next));
122+
VALGRIND_HG_DISABLE_CHECKING(&end, sizeof(end));
123+
VALGRIND_HG_DISABLE_CHECKING(&written, sizeof(written));
124+
125+
for (size_t i = 0; i < max_workers; i++) {
126+
VALGRIND_HG_DISABLE_CHECKING(
127+
&workers[i].seen_off,
128+
sizeof(workers[i].seen_off));
129+
VALGRIND_HG_DISABLE_CHECKING(
130+
&workers[i].registered,
131+
sizeof(workers[i].registered));
132+
}
133+
#endif
118134
}
119135
};
120136

@@ -185,7 +201,7 @@ stable_seenoff(ringbuf_worker_t *w)
185201
* => On success: returns the offset at which the space is available.
186202
* => On failure: returns -1.
187203
*/
188-
inline ssize_t
204+
inline ptrdiff_t
189205
ringbuf_acquire(ringbuf_t *rbuf, ringbuf_worker_t *w, size_t len)
190206
{
191207
ringbuf_off_t seen, next, target;
@@ -286,7 +302,7 @@ ringbuf_acquire(ringbuf_t *rbuf, ringbuf_worker_t *w, size_t len)
286302
std::memory_order_release);
287303
}
288304
assert((target & RBUF_OFF_MASK) <= rbuf->space);
289-
return (ssize_t)next;
305+
return (ptrdiff_t)next;
290306
}
291307

292308
/*

0 commit comments

Comments
 (0)