# BitVector Adapt GPUs

**URL:** <https://discourse.julialang.org/t/bitvector-adapt-gpus/86500>\
**Category:** GPU\
**Created:** [August 29, 2022, 1:37pm UTC](https://discourse.julialang.org/t/bitvector-adapt-gpus/86500 "2022-08-29T13:37:47Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![Allan\_Baker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/allan_baker/32/42645_2.png) [@Allan\_Baker](https://discourse.julialang.org/u/Allan_Baker)\
**Post date:** [August 31, 2022, 12:36pm UTC](https://discourse.julialang.org/t/bitvector-adapt-gpus/86500/21 "2022-08-31T12:36:47Z")

</div>

Can’t walk thought debugger as the logic happens with the typeof. Do you know what this means,

```julia
julia> typeof(wfcw64).flags
0x72

julia> typeof(wfcw64).flags & 0x08
0x00

```

typeof(x).flags & 0x08 == 0x08 to pass the isbits.

---

<div class="post-metadata">

**Author:** ![Allan\_Baker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/allan_baker/32/42645_2.png) [@Allan\_Baker](https://discourse.julialang.org/u/Allan_Baker)\
**Post date:** [August 31, 2022, 1:44pm UTC](https://discourse.julialang.org/t/bitvector-adapt-gpus/86500/22 "2022-08-31T13:44:04Z")

</div>

This fixes it. Don’t know if it is as expected

```julia
struct Waveform{T<:ValidWFType,CT<:NTuple,PMT<:PulseModulationStyle{T,CT}}  
    ...
   compression::PMT 
end

julia> @show isbits(wfcw64)
isbits(wfcw64) = true

```

---

<div class="post-metadata">

**Author:** ![ToucheSir](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/touchesir/32/14411_2.png) [@ToucheSir](https://discourse.julialang.org/u/ToucheSir)\
**Post date:** [August 31, 2022, 2:45pm UTC](https://discourse.julialang.org/t/bitvector-adapt-gpus/86500/23 "2022-08-31T14:45:26Z")

</div>

It is, good going.

One more note on

> [@Allan\_Baker](#):
>
> I think I have that BinaryCode working now. I had to go to something like this, but it passes the isbitstype check.

There’s some subtlety to this that I didn’t explain, partially out of laziness. `CT<:AbstractVector` _does_ work on GPU, but I presume you ditched it because `isbits()` was always false. Why does it work on GPU then? That’s because CUDA.jl actually automatically converts `CuArray`s (not isbits) to `CuDeviceArray`s (isbits) before passing them to a kernel. This happens behind the scenes so you don’t notice it most of the time, but if you were to `@cuprintf typeof(array)` in a kernel you would.

---

<div class="post-metadata">

**Author:** ![Allan\_Baker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/allan_baker/32/42645_2.png) [@Allan\_Baker](https://discourse.julialang.org/u/Allan_Baker)\
**Post date:** [September 7, 2022, 4:01pm UTC](https://discourse.julialang.org/t/bitvector-adapt-gpus/86500/24 "2022-09-07T16:01:27Z")

</div>

Thanks for that clarification. I have another issue that I don’t know the best way to define a vector of these items.

Say I have that Waveform object above:

```julia
struct 
Waveform{T<:ValidWFType,CT<:NTuple,PMT<:PulseModulationStyle{T,CT}}  

mutable struct TransmissionBuffer{W<:Waveform}
	buffer::Vector{W}
	maximumSize::Int # The number to allow before wrapping around
end

tb=TransmissionBuffer{???}(10)

```

What do I put in the ??? place, so I can add Waveforms that may have different compression types.

---

<div class="post-metadata">

**Author:** ![Allan\_Baker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/allan_baker/32/42645_2.png) [@Allan\_Baker](https://discourse.julialang.org/u/Allan_Baker)\
**Post date:** [September 10, 2022, 2:40am UTC](https://discourse.julialang.org/t/bitvector-adapt-gpus/86500/25 "2022-09-10T02:40:39Z")

</div>

It appears that TransmissionBuffer{Waveform})10 works just fine.

The problem I’m having is converting the Vector of Waveforms that Transmission buffer has, into a CuArray. The CuArray only supports element types tha are stored inline.

I naively thought I could just do something like this: CuArray{W}(TB.buffer) where TB is the transmissionBuffer which has a vector of {W}.

Does anyone know the correct syntax to convert a vector of the Waveform object to a CuArray of Waveform Objects.

---

<div class="post-metadata">

**Author:** ![Allan\_Baker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/allan_baker/32/42645_2.png) [@Allan\_Baker](https://discourse.julialang.org/u/Allan_Baker)\
**Post date:** [September 11, 2022, 9:52pm UTC](https://discourse.julialang.org/t/bitvector-adapt-gpus/86500/26 "2022-09-11T21:52:54Z")

</div>

It seems like I have a fundamental flaw. The “waveform type” I have created has a PulseModulationType which can be currently one of three vastly different types and memory sizes.

I’m not sure how I am able to resolve this. I may try to come-up with another example that is easier to push on these forums.

[Previous page](https://discourse.julialang.org/t/bitvector-adapt-gpus/86500.md?page=1)
