Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions omnilink/concurrentqueue/ConcurrentQueueAPI.tla
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ Next ==
QueueTryEnqueueBulk(elements, count, success, thread)
\/ \E thread \in Threads, element \in Elements, success \in BOOLEAN :
QueueTryDequeue(element, success, thread)
\/ \E elements \in BulkBufferSet, max \in 1..MaxBulkSize, count \in 0..MaxBulkSize, producers \in Seq(Threads) :
QueueTryDequeueBulk(elements, max, count, producers)
\* \/ \E elements \in BulkBufferSet, max \in 1..MaxBulkSize, count \in 0..MaxBulkSize, producers \in Seq(Threads) :
\* QueueTryDequeueBulk(elements, max, count, producers)
\* \/ \E thread \in Threads, element \in Elements, success \in BOOLEAN :
\* QueueTryDequeueFromProducer(thread, element, success, thread)
\* \/ \E thread \in Threads, elements \in BulkBufferSet, max \in 1..MaxBulkSize, count \in 0..MaxBulkSize, producers \in Seq(Threads) :
Expand Down
9 changes: 5 additions & 4 deletions omnilink/concurrentqueue/MCConcurrentQueueAPIValidate.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ NEXT Next
CONSTANTS
Elements <- ElementsImpl
Threads <- ThreadsImpl

MaxElements = 5
MaxBulkSize = 3
\* MaxElements <- MaxElementsImpl
\* MaxBulkSize <- MaxBulkSizeImpl
MaxElements = 1000
MaxBulkSize = 5

INVARIANTS
TypeOK
Expand All @@ -17,5 +18,5 @@ ALIAS DebugAlias
POSTCONDITION PostCondition
CHECK_DEADLOCK FALSE

VIEW PragmaticView
\* VIEW PragmaticView

31 changes: 31 additions & 0 deletions omnilink/concurrentqueue/MCConcurrentQueueAPIValidate.tla
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,38 @@ ThreadsImpl == TLCCache(
: i \in DOMAIN __traces[t] }
: t \in DOMAIN __traces }, {"ThreadsImpl"})

\* MaxOrZero(S) ==
\* IF S = {} THEN 0
\* ELSE CHOOSE m \in S : \A x \in S : x <= m

\* MaxElementsImpl == TLCCache(
\* LET diffs == UNION {
\* UNION {
\* IF "state" \in DOMAIN __traces[t][i]
\* /\ "enqueued" \in DOMAIN __traces[t][i].state
\* /\ "dequeued" \in DOMAIN __traces[t][i].state
\* THEN { __traces[t][i].state.enqueued - __traces[t][i].state.dequeued }
\* ELSE {}
\* : i \in DOMAIN __traces[t] }
\* : t \in DOMAIN __traces }
\* IN MaxOrZero(diffs),
\* {"MaxElementsImpl"}
\* )

\* MaxBulkSizeImpl == TLCCache(
\* LET Ops ==
\* UNION { { __traces[t][i].operation :
\* i \in DOMAIN __traces[t] } :
\* t \in DOMAIN __traces }
\* OpsWithEls ==
\* { op \in Ops : "elements" \in DOMAIN op }
\* Counts ==
\* { Len(op.elements) : op \in OpsWithEls }
\* IN MaxOrZero(Counts),
\* {"MaxBulkSizeImpl"}
\* )


DebugAlias == __TraceOps!DebugAlias
PostCondition == __TraceOps!PostCondition

Expand Down
4 changes: 2 additions & 2 deletions omnilink/concurrentqueue/package.mill
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ object `package` extends Module:
object v1_0_4 extends CQTracingConfigModule:
def nixName = "omnilink.concurrentqueue.workload"
object defaultConfig extends ConfigModule:
def threadCount = 2
def operationCount = 1
def threadCount = 5
def operationCount = 10
end defaultConfig
end v1_0_4

Expand Down
51 changes: 25 additions & 26 deletions omnilink/concurrentqueue/workload/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ struct QueueWorkloadContext: public omnilink::WorkloadContext<QueueWorkloadConte
producer_thread = *resolved;
}
}

ctx.op.thread = producer_thread;
}

Expand All @@ -231,31 +230,31 @@ struct QueueWorkloadContext: public omnilink::WorkloadContext<QueueWorkloadConte
// };
// }

void perform_operation(Ctx<ConcurrentQueueAPI::QueueTryDequeueBulk>& ctx) {
int32_t max = rand_bulk_size();
std::vector<int32_t> elements(max);
size_t dequeued = workload_context.queue.try_dequeue_bulk(elements.data(), max);
if (dequeued < static_cast<size_t>(elements.size())) {
elements.resize(dequeued);
}
std::vector<int32_t> producer_threads;
if (dequeued > 0) {
if (auto resolved = workload_context.resolve_producers_for_bulk(elements.data(), dequeued)) {
producer_threads = std::move(*resolved);
}
}
ctx.op = ConcurrentQueueAPI::QueueTryDequeueBulk{elements, max, static_cast<int32_t>(dequeued)};
std::map<std::string, omnilink::Packable> meta{
{"consumer_thread", static_cast<int32_t>(thread_idx)}
};
if (!producer_threads.empty()) {
meta["producer_threads"] = producer_threads;
ctx.op.producers = producer_threads;
} else {
ctx.op.producers = std::vector<int32_t>{};
}
ctx.op._meta = std::move(meta);
}
// void perform_operation(Ctx<ConcurrentQueueAPI::QueueTryDequeueBulk>& ctx) {
// int32_t max = rand_bulk_size();
// std::vector<int32_t> elements(max);
// size_t dequeued = workload_context.queue.try_dequeue_bulk(elements.data(), max);
// if (dequeued < static_cast<size_t>(elements.size())) {
// elements.resize(dequeued);
// }
// std::vector<int32_t> producer_threads;
// if (dequeued > 0) {
// if (auto resolved = workload_context.resolve_producers_for_bulk(elements.data(), dequeued)) {
// producer_threads = std::move(*resolved);
// }
// }
// ctx.op = ConcurrentQueueAPI::QueueTryDequeueBulk{elements, max, static_cast<int32_t>(dequeued)};
// std::map<std::string, omnilink::Packable> meta{
// {"consumer_thread", static_cast<int32_t>(thread_idx)}
// };
// if (!producer_threads.empty()) {
// meta["producer_threads"] = producer_threads;
// ctx.op.producers = producer_threads;
// } else {
// ctx.op.producers = std::vector<int32_t>{};
// }
// ctx.op._meta = std::move(meta);
// }

// void perform_operation(Ctx<ConcurrentQueueAPI::QueueTryDequeueBulkWithToken>& ctx) {
// int32_t max = rand_bulk_size();
Expand Down
Loading