swap

How to effectively swap OpenCL memory buffers?

99封情书 提交于 2020-01-02 03:39:06
问题 Exactly as the title suggests I am looking for how to effectively swap two OpenCL buffers. My kernel uses two gloabl buffers, one as input and one as output. However, I invoke my kernel in a for loop with the same NDRange, each time setting the kernel arguments, enqueueing the kernel, and swapping the buffers because the previous output buffer will be the input buffer seed for the next iteration. What is the appropriate way here, to swap these two buffers? I imagine that copying the buffer

Swapping ms-sql tables

只愿长相守 提交于 2019-12-31 18:59:57
问题 I want to swap to tables in the best possible manner. I have an IpToCountry table, and I create a new one on a weekly basis according to an external CSV file which I import. The fastest way I've found to make the switch was doing the following: sp_rename IpToCountry IpToCountryOld go sp_rename IpToCountryNew IpToCountry go The problem with this is that the table might still be accessed in between. How do I approach this problem in SQL? In considered using sp_getapplock and sp_releaseapplock,

Linker performance related to swap space?

家住魔仙堡 提交于 2019-12-31 10:10:08
问题 Sometimes it's handy to mock up something with a little C program that uses a big chunk of static memory. I noticed after changing to Fedora 15 the program took a long time to compile. We're talking 30s vs. 0.1s. Even more weird was that ld (the linker) was maxing out the CPU and slowly started eating all available memory. After some fiddling I managed to find a correlation between this new problem and the size of my swap file. Here's an example program for the purposes of this discussion:

How to swap two __m128i variables in C++03 given its an opaque type and an array?

♀尐吖头ヾ 提交于 2019-12-30 10:38:08
问题 What is the best practice for swapping __m128i variables? The background is a compile error under Sun Studio 12.2, which is a C++03 compiler. __m128i is an opaque type used with MMX and SSE instructions, and its usually and unsigned long long[2] . C++03 does not provide the support for swapping arrays, and std:swap(__m128i a, __m128i b) fails under the compiler. Here are some related questions that don't quite hit the mark. They don't apply because std::vector is not available. How can we

Does STL sort use swap or binary copy?

你说的曾经没有我的故事 提交于 2019-12-30 08:10:13
问题 I'm having trouble finding a good answer to this. For some reason I thought STL sort would be implemented using swap for better support of complicated types, but as I ended up digging through the code a bit it appears it is actually doing a binary copy. Can someone confirm this? I guess binary copy would actually be preferred to swap. Side Question : Are any of the STL algorithms or container operations implemented using swap? (Outside of std::swap obviously.) I want to be aware of when it is

How to copy (or swap) objects of a type that contains members that are references or const?

瘦欲@ 提交于 2019-12-29 04:45:09
问题 The problem I am trying to address arises with making containers such as an std::vector of objects that contain reference and const data members: struct Foo; struct Bar { Bar (Foo & foo, int num) : foo_reference(foo), number(num) {} private: Foo & foo_reference; const int number; // Mutable member data elided }; struct Baz { std::vector<Bar> bar_vector; }; This won't work as-is because the default assignment operator for class Foo can't be built due to the reference member foo_reference and

Python Simple Swap Function

余生颓废 提交于 2019-12-29 04:44:07
问题 I came across this problem when attempting to learn python. Consider the following function: def swap0(s1, s2): assert type(s1) == list and type(s2) == list tmp = s1[:] s1 = s2[:] s2 = tmp return s1 = [1] s2 = [2] swap0(s1, s2) print s1, s2 What will s1 and s2 print? After running the problem, I found that the print statement will print 1 2. It seems that the value of s1 and s2 did not change from the swap0 function. The only explanation that I could think of was because of the line. tmp = s1

Why don't people use xor swaps? [closed]

泪湿孤枕 提交于 2019-12-28 19:16:19
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . I read on a site that using xor swaps is fast because it doesn't use a temporary variable. Here's an example: #include <stdio.h> int

Is specializing std::swap deprecated now that we have move semantics? [duplicate]

雨燕双飞 提交于 2019-12-28 12:12:41
问题 This question already has answers here : Closed 6 years ago . Possible Duplicate: Move semantics == custom swap function obsolete? This is how std::swap looks like in C++11: template<typename T> void swap(T& x, T& y) { T z = std::move(x); x = std::move(y); y = std::move(z); } Do I still have to specialize std::swap for my own types, or will std::swap be as efficient as it gets, provided that my class defines a move constructor and a move assignment operator, of course? 回答1: The specialization

Finding the minimum number of swaps to convert one string to another, where the strings may have repeated characters

蓝咒 提交于 2019-12-28 05:23:11
问题 I was looking through a programming question, when the following question suddenly seemed related. How do you convert a string to another string using as few swaps as follows. The strings are guaranteed to be interconvertible (they have the same set of characters, this is given), but the characters can be repeated . I saw web results on the same question, without the characters being repeated though. Any two characters in the string can be swapped. For instance : "aabbccdd" can be converted