Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
0acd9b9
update to remove implicit thrust vector host to device copy
JPRichings Apr 25, 2026
d7bf558
remove thrust devic_vector
JPRichings Apr 28, 2026
324e5be
alternative approach where capture array in struct to remove explict …
JPRichings May 5, 2026
e04dc1f
identify opportutnities for performance improvement
JPRichings May 9, 2026
abf0387
kernel_statevec_anyCtrlSwap_subA performance change
JPRichings May 9, 2026
a3cd184
update kernel_statevec_anyCtrlSwap_subB for performance
JPRichings May 9, 2026
5dd472d
update kernel_statevec_anyCtrlSwap_subC for performance
JPRichings May 9, 2026
a23b231
update kernel_statevec_anyCtrlOneTargDenseMatr_subB for performance
JPRichings May 9, 2026
6ea9d76
update kernel_statevec_anyCtrlTwoTargDenseMatr_sub for performance
JPRichings May 9, 2026
5ef2d27
update kernel_statevec_anyCtrlFewTargDenseMatr for performance
JPRichings May 9, 2026
a353450
update kernel_statevector_anyCtrlPauliTensorOrGadget_subA for perform…
JPRichings May 9, 2026
1f57274
update kernel_statevector_anyCtrlPauliTensorOrGadget_subA for perform…
JPRichings May 9, 2026
6604823
update kernel_statevector_anyCtrlPauliTensorOrGadget_subB for perform…
JPRichings May 9, 2026
ca95173
update kernel_densmatr_partialTrace_sub for performance
JPRichings May 9, 2026
ec71af6
update kernel_statevec_calcProbsOfAllMultiQubitOutcomes_sub for perfo…
JPRichings May 9, 2026
7e5e92d
update kernel_densmatr_calcProbsOfAllMultiQubitOutcomes_sub for perfo…
JPRichings May 9, 2026
89b6951
update kernel_statevec_anyCtrlAnyTargDiagMatr_sub for performance
JPRichings May 9, 2026
8e24362
add const arg versions of bitwise functions
JPRichings May 9, 2026
1cd9150
debug performance changes
JPRichings May 9, 2026
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
38 changes: 37 additions & 1 deletion quest/src/core/bitwise.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,15 @@ INLINE qindex insertBits(qindex number, int* bitIndices, int numIndices, int bit
return number;
}

INLINE qindex insertBits(qindex number, const int* bitIndices, int numIndices, int bitValue) {

// bitIndices must be strictly increasing
for (int i=0; i<numIndices; i++)
number = insertBit(number, bitIndices[i], bitValue);

return number;
}


INLINE qindex setBits(qindex number, int* bitIndices, int numIndices, qindex bitsValue) {

Expand All @@ -182,6 +191,17 @@ INLINE qindex setBits(qindex number, int* bitIndices, int numIndices, qindex bit
return number;
}

INLINE qindex setBits(qindex number, const int* bitIndices, int numIndices, qindex bitsValue) {

// bitIndices are arbitrarily ordered, which does not affect number
for (int i=0; i<numIndices; i++) {
int bit = getBit(bitsValue, i);
number = setBit(number, bitIndices[i], bit);
}

return number;
}


INLINE qindex getValueOfBits(qindex number, int* bitIndices, int numIndices) {

Expand All @@ -194,6 +214,16 @@ INLINE qindex getValueOfBits(qindex number, int* bitIndices, int numIndices) {
return value;
}

INLINE qindex getValueOfBits(qindex number, const int* bitIndices, int numIndices) {

// bits are arbitrarily ordered, which affects value
qindex value = 0;

for (int i=0; i<numIndices; i++)
value |= getBit(number, bitIndices[i]) << i;

return value;
}


/*
Expand All @@ -209,6 +239,12 @@ INLINE qindex insertBitsWithMaskedValues(qindex number, int* bitInds, int numBit
return mask | insertBits(number, bitInds, numBits, 0);
}

INLINE qindex insertBitsWithMaskedValues(qindex number, const int* bitInds, int numBits, qindex mask) {

// bitInds must be sorted (increasing), and mask must be zero everywhere except bitInds
return mask | insertBits(number, bitInds, numBits, 0);
}


INLINE int getTwoBits(qindex number, int highInd, int lowInd) {

Expand Down Expand Up @@ -377,4 +413,4 @@ INLINE void getBitsFromInteger(int* bits, qindex number, int numBits) {



#endif // BITWISE_HPP
#endif // BITWISE_HPP
Loading