Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Ready] Fast Concurrent Deque Through Explicit Timestamping #127

Open
wants to merge 30 commits into
base: integration
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
9d2f2af
Init ts_deque
pr3sto Dec 4, 2018
4e31819
init deque_buffer
EduardBlees Dec 6, 2018
fff2b21
Merge branch 'develop' of github.com:EduardBlees/libcds into develop
EduardBlees Dec 6, 2018
c20d3c3
init timestamp
vikkiorrikki Dec 6, 2018
86ff17d
add Item and initialize method
pr3sto Dec 8, 2018
c7c96bf
try remove left impl
EduardBlees Dec 10, 2018
9f6d53e
threadcontext
EduardBlees Dec 10, 2018
92efc84
implement insert_right
pr3sto Dec 12, 2018
a136c71
timestamp hardware
vikkiorrikki Dec 12, 2018
0dcef53
insert_left implementation
pr3sto Dec 13, 2018
7fdf05c
try remove right impl
EduardBlees Dec 15, 2018
ab723b5
timestamp hardware interval
vikkiorrikki Dec 15, 2018
b2a8b91
implement ts_deque
pr3sto Dec 16, 2018
0178ecb
methods for fixing aba problem added
pr3sto Dec 16, 2018
2bb8dce
try remove fixes, use ABA functions
EduardBlees Dec 17, 2018
06542ae
fixes insert methods
pr3sto Dec 18, 2018
09052d7
timestamp atomic counter
vikkiorrikki Dec 19, 2018
546b8b3
assign threadcontext to each thread
pr3sto Dec 19, 2018
0e4fd30
code format
EduardBlees Dec 20, 2018
0181934
add clear, size and empty methods
pr3sto Dec 23, 2018
c4ecac4
prepare to pull request
pr3sto Dec 24, 2018
eb5e9f6
add unit tests
pr3sto Dec 24, 2018
a5ecc16
move asm code to compiler folder
pr3sto Dec 24, 2018
72f5ef0
fix
pr3sto Dec 24, 2018
ac02558
add copyright note
pr3sto Dec 25, 2018
430297f
fix emptyness check, thread_id
pr3sto Dec 27, 2018
ff40ba7
stress tests added
pr3sto Dec 28, 2018
5ee65b5
fix tests for different architectures
pr3sto Jan 16, 2019
d5ece4c
fix rdtsc and rdtscp for i386 arch
pr3sto Jan 16, 2019
2410e88
add rdtscp check
pr3sto Jan 18, 2019
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
10 changes: 10 additions & 0 deletions cds/compiler/gcc/amd64/ts_hardwaretimestamp.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define CDSLIB_COMPILER_GCC_AMD64_TS_HARDWARETIMESTAMP_H

#include <cstdint>
#include <cpuid.h>

namespace cds { namespace tshardwaretimestamp {
namespace gcc { namespace amd64 {
Expand All @@ -23,6 +24,15 @@ namespace cds { namespace tshardwaretimestamp {
return ((uint64_t)low) | (((uint64_t)high) << 32);
}

static inline int has_rdtscp()
{
unsigned int eax, ebx, ecx, edx;
if (__get_cpuid(0x80000001, &eax, &ebx, &ecx, &edx))
return (edx >> 27) & 0x1;
else
return 0;
}

}} // namespace gcc::amd64

namespace platform {
Expand Down
10 changes: 10 additions & 0 deletions cds/compiler/gcc/x86/ts_hardwaretimestamp.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define CDSLIB_COMPILER_GCC_X86_TS_HARDWARETIMESTAMP_H

#include <cstdint>
#include <cpuid.h>

namespace cds { namespace tshardwaretimestamp {
namespace gcc { namespace x86 {
Expand All @@ -22,6 +23,15 @@ namespace cds { namespace tshardwaretimestamp {
return ret;
}

static inline int has_rdtscp()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's quit strange to have "has_..." function returning logically boolean value with int signature

{
unsigned int eax, ebx, ecx, edx;
if (__get_cpuid(0x80000001, &eax, &ebx, &ecx, &edx))
return (edx >> 27) & 0x1;
else
return 0;
}

}} // namespace gcc::x86

namespace platform {
Expand Down
39 changes: 23 additions & 16 deletions test/unit/deque/ts_deque.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <cds_test/ext_gtest.h>
#include <cds/container/ts_deque.h>
#include <cds/container/ts_timestamp.h>
#include <cds/compiler/ts_hardwaretimestamp.h>

namespace {

Expand Down Expand Up @@ -81,26 +82,32 @@ namespace {

TEST_F( TSDeque, hardware_timestamping )
{
typedef cds::container::TSDeque<int, cds::container::HardwareTimestamp,
cds::container::tsdeque::make_traits<
cds::opt::item_counter< cds::atomicity::item_counter >
>::type
> deque_type;

deque_type dq(1, 0);
test( dq );
if (cds::tshardwaretimestamp::platform::has_rdtscp() == 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You check rdtscp existence only in unit tests, but what should do developers who will use your API, the same? It should be transparent for users

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Проблема в том, что, как я понял, нет возможности проверить наличие rdtscp во время компиляции. Эту проверку необходимо делать во время выполнения программы. Я не знаю, как сделать это прозрачным для пользователей. Подскажите?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's possible to determine it through cpuid like this

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не совсем понимаю, что вы имеете ввиду. У нас и так проверка наличия rdtscp происходит с помощью cpuid. И функция cds::tshardwaretimestamp::platform::has_rdtscp() возвращает 1, если процессор поддерживает rdtscp.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Всё верно, я сначала ответил на вопрос, а потом посмотрел реализацию

{
typedef cds::container::TSDeque<int, cds::container::HardwareTimestamp,
cds::container::tsdeque::make_traits<
cds::opt::item_counter< cds::atomicity::item_counter >
>::type
> deque_type;

deque_type dq(1, 0);
test( dq );
}
}

TEST_F( TSDeque, hardware_interval_timestamping )
{
typedef cds::container::TSDeque<int, cds::container::HardwareIntervalTimestamp,
cds::container::tsdeque::make_traits<
cds::opt::item_counter< cds::atomicity::item_counter >
>::type
> deque_type;

deque_type dq(1, 100000);
test( dq );
if (cds::tshardwaretimestamp::platform::has_rdtscp() == 1)
{
typedef cds::container::TSDeque<int, cds::container::HardwareIntervalTimestamp,
cds::container::tsdeque::make_traits<
cds::opt::item_counter< cds::atomicity::item_counter >
>::type
> deque_type;

deque_type dq(1, 100000);
test( dq );
}
}

#endif
Expand Down