Posts

How to overwrite ProductDefinition defaults?

 Question: \Shopware\Core\Content\Product\ProductDefinition::getDefaults defines default values for a few fields:     public function getDefaults(): array     {         return [             'isCloseout' => false,             'minPurchase' => 1,             'purchaseSteps' => 1,             'shippingFree' => false,             'restockTime' => null,             'active' => true,             'markAsTopseller' => false,         ];     } When creating a product via REST API and one of the fields is omitted the corresponding default value is used. In our case we create and update products via REST API but we need to manage the active field form within Shopware. When a product is created it s...

Per-element atomicity of vector load/store and gather/scatter?

Question: Consider an array like   atomic<int32_t> shared_array[] . What if you want to SIMD vectorize   for(...) sum += shared_array[i].load(memory_order_relaxed) ?. Or to search an array for the first non-zero element, or zero a range of it? It's probably rare, but consider   any use-case where tearing within an element is not allowed, but reordering between elements is fine.   (Perhaps a search to find a candidate for a CAS). I  think  x86 aligned vector loads/stores would be safe in practice to use on for SIMD with  mo_relaxed  operations, because any tearing will only happen at 8B boundaries at worst on current hardware (because that's what makes naturally-aligned 8B accesses atomic 1 ). Unfortunately Intel's manuals only say: "An x87 instruction or an SSE instructions that accesses data larger than a quadword may be implemented using multiple memory accesses." There's no guarantee that those component accesses are naturally aligned, no...