einpoklum

1

votes
1

answer
26

views

Naming the outputs of a pop vs a shift operation on a sequence of elements

I'm defining a push and a shift operation in some programming-language-like project of mine (which is irrelevant to this question) - on an ordered finite sequence of elements. Their semantics will be: Shift: Remove the first element from the sequence (so the second element becomes the first, third b...
einpoklum
1

votes
0

answer
82

views

Elegence and terseness with structure-of-arrays as opposed to array-of-structs

Suppos I need to hold some data consisting of n Foo's, n Bars and n Bazs. The elements of corresponding indices are related, so you can also think of this data as n triplets of Foo, Bar andBaz`. The first description of the data is a 'structure of arrays', the second is an 'array of structures'; you...
einpoklum
2

votes
1

answer
87

views

How do I determine the largest pointer size on my platform?

In (C and) C++, pointers to different types don't necessarily have the same size. I would have hoped void * is necessarily the largest, but it seems not even this is actually guaranteed. My question: How can I determine what the largest size of a pointer is on my (compilation target) platform? Note:...
einpoklum
1

votes
1

answer
112

views

VIM ignores my tab-related settings in ~/.vimrc (and paste is not set)

Here's my ~/.vimrc on some machine: set softtabstop=0 noexpandtab nosmarttab set shiftwidth=4 set tabstop=4 colorscheme murphy ... but when I edit files, tabs show up as 8 spaces, and typing in a tab produces for spaces. I looked around and found this question: set expandtab in .vimrc not taking e...
einpoklum
1

votes
0

answer
25

views

Can I make Eclipse filter-out resources matched by .gitignore?

I'm importing some git repository as an Eclipse (CDT) project. I would like to have all resources which are matched by .gitignore filtered out of view - either dynamically, or by having resource filters created for them upon import. Is this possible?
einpoklum
1

votes
0

answer
23

views

Is there a significant benefit to partitioning rather than pivoting when (quick)sorting?

In each phase of the Quick-Sort algorithm, a pivot is chosen, and the data is bi-partitioned into elements below and above the pivot (and some tie breaking for being equal to it). Now, each pivoting requires a pass over the data. Also, the variance of the pivot's relative position around being the m...
einpoklum
1

votes
0

answer
111

views

How do gsl::string_span and std::string_view differ?

From what I can gather, gsl::string_span and std::string_view seem to have essentially the same rationale for use. Is that indeed the case? If so, are they effectively identical? If not - how do they differ? Related question: What purpose does `gsl::string_span` aim at?
einpoklum
1

votes
0

answer
59

views

gcc and clang not willing to lazily initialize a partially-used struct

Consider the following code: __attribute__((noinline)) int foo1(int x, int y) { return x; } int bar1(int* a) { int b = foo1(a[5], a[10]); return b * b; } Even though foo1 is not inlined, a compiler can easily tell one of its parameters is unused; so it's not actually necessary to bother initializing...
einpoklum
1

votes
0

answer
14

views

General-purpose/generic test for container requirements compliance?

Suppose you're writing a container, to meet the C++ container requirements. What should I do to make sure it's properly compliant? And Is it possible to have some general-purpose compliance 'torture' test into which you plug any container's code and it passes compilation if and only if you actually...
einpoklum
1

votes
0

answer
40

views

How do I doxygen-document unnamed parameters of a function?

With doxygen, I'm used to write /** * @brief blah blah * * @param foo description of foo * @param bar description of bar * @return description of the return value */ int f(int foo, unsigned bar); But what if I don't name one of the parameter? : int f(int, unsigned bar); How can I document this param...
einpoklum
1

votes
2

answer
606

views

What's a good Java idiom for concatenating multiple lists with a single command? [duplicate]

I want to concatenate multiple lists with a single command, e.g. to do something like: myFirstList.concat(mySecondList).concat(myThirdList); or maybe List.concat(myFirstList, mySecondList,myThirdList); i.e. I'd like something like List concat(List additional); as a member of List (can't have that, I...
einpoklum
1

votes
1

answer
512

views

Need MySQL idiom for checking whether string contains any of a set of characters

I need to run the following MySQL query: SELECT id, name FROM mytable WHERE NOT CONTAINS_ANY(name, ';.#$!'); except that there doesn't seem to be anything like CONTAINS_ANY (taking two string and checking whether the first string contains any character of those in the second string). What can I do...
einpoklum
1

votes
1

answer
1.6k

views

Can I combine two Eclipse download packages?

I'm about to install Eclipse Kepler, from scratch. Now, the download page has, among others, both an 'Eclipse IDE for 'Eclipse for Parallel Application Developers' and a 'Eclipse IDE for C/C++ Developers Eclipse IDE for C/C++ Developers. The former is larger in size than the standard package, so cle...
einpoklum
1

votes
2

answer
1.1k

views

should I symlink the C++ include directory so that it also appears under /usr/include?

I'm using Cygwin32 on Win7 64. I have g++ and libstdc++ installed. The C++ includes are located at /usr/lib/gcc/i686-pc-cygwin/4.8.2/include/c++/tr1/ - but nowhere under /usr/include. Is it reasonable to place them, by symlink, under /usr/include? If not, why? And if so, why isn't this done by defa...
einpoklum
1

votes
2

answer
98

views

Automating the addition of Java-enum-like capabilities for an enum

In Java, enums come with several capabilities missing from C/C++ enums. I would like to be able to define enums with, say, some macro ENUM(Color, Red, Green, Blue) or ENUM(Color, {Red, Green, Blue} ) or what-not, and have an enum defined with these capabilities implemented somehow. Specifically, I...
einpoklum
1

votes
1

answer
119

views

std::sort comparator which sees the element's (original) index

I would like to std::partial_sort_copy() an array, but using a custom comparator function. The thing is, this function uses both the values of the array cells being compared and their indices. For the sake of discussion, suppose my comaprison function is something like template bool myCompare(size_...
einpoklum
1

votes
2

answer
1k

views

What's the 'right' way to implement a 32-bit memset for CUDA?

CUDA has the API call cudaError_t cudaMemset (void *devPtr, int value, size_t count) which fills a buffer with a single-byte value. I want to fill it with a multi-byte value. Suppose, for the sake of simplicity, that I want to fill devPtr with a 32-bit (4-byte) value, and suppose we can ignore endia...
einpoklum
1

votes
1

answer
163

views

How can I escape characters using ASCII 3-letter codes?

I want something like string magic(char c); so that when I do std::cout
einpoklum
1

votes
1

answer
748

views

In MonetDB, how can I get the date as an integer?

I want to be able to do something like SELECT cast(my_date_col AS int) FROM my_table; I would like to get the integer which MonetDB uses internally, i.e. the value you'd find if you looked into the BAT structure and got the appropriate element in code in MonetDB's GDK. Now, AFAICT, this internal val...
einpoklum
1

votes
1

answer
190

views

Which atomics targetting pattern is better for a GPU warp: All-the-same or all-distinct?

Suppose we have: A single warp (of 32 threads) Each thread t which has 32 int values val t,0...val t,31, Each value val t,i needs to be added, atomically, to a variable desti, which resides in (Option 1) global device memory (Option 2) shared block memory. Which access pattern would be faster to pe...
einpoklum
1

votes
2

answer
270

views

When should I use Boost's lexical_cast? Is it a mechanism of last

Boost's lexical_cast, which converts numbers (or arbitrary objects) to strings and back. Should I try to use it more, say, instead of streaming things to std::stringstreams? Or is it more of a mechanism-of-last-resort? Here's one example of two alternative approaches: std::stringstream message; mess...
einpoklum
1

votes
1

answer
279

views

Is there a Windows equivalent of standard(ish) UN*X process exit codes?

I need to decide which exit code to exit() with in different scenarios. I just read Are there any standard exit status codes in Linux? but I need to write something that is (sort of) cross-platform Linux+Windows. MS Windows does not seem to have something like /usr/include/sysexits.h; it only has C8...
einpoklum
1

votes
2

answer
228

views

Why does inline void foo() { … } in a common header just work?

Consider the use of inline in C99, with various options (extern'ing, static inline etc), as described here, for example. I don't understand why the C standard does not allow for just using void inline foo() { do_stuff(); } in a common header file, and for that to work everywhere. Why do I have to a...
einpoklum
1

votes
1

answer
277

views

Eclipse SVN Team View “Add to Version Control” is grayed out - why?

I'm working on a project in Eclipse, and our version control is in Subversion. My exact Eclipse info is Eclipse CDT Mars, 4.5.1, with Subclipse 1.10.9 . So, I created this extran file, and I want to add it to version control, but - for some reason that's grayed out on the team menu, along with some...
einpoklum
0

votes
1

answer
23

views

Do _Complex types in C11 behave like std::complex<> in C++?

I've recently noticed the existence of new types for complex values introduced in C11 (!). Since this is C, these are built-in types, not structs with overloaded operators etc. But - is it or is it not the case that I can treat them as though they were based on C++'s std::complex template? i..e. is...
einpoklum
1

votes
1

answer
443

views

Eclipse CDT fails to resolve most standard library constructs

I'm using Eclipse CDT Mars (and sometimes Cevelop) on Debian Stretch (and sometimes on Fedora 22), to write some C++ code. My project is properly defined, in Eclipse and it even builds when I'm temporarily out of bugs. However...... most (or all) of the C++ standard library constructs are marked as...
einpoklum
1

votes
1

answer
136

views

Is there an opposite to cudaHostGetDevicePointer()?

Suppose my device is Kepler and up, CUDA is 6.5 or up, and my driver is from 2015 at the earliest. Is it possible to do the opposite of cudaHostGetDevicePointer()? i.e., provided the address of the device-side manifestation of some mapped memory, obtain the host address?
einpoklum
1

votes
1

answer
523

views

How can I view the contents of an std::map in Eclipse?

I'm trying to view the contents on an std::map using Eclipse CDT, but all I seem to see is a(n infinite?) tree of red-and-black tree nodes. Where's the actual data? How come CDT doesn't offer some pretty-printed view of the contents of the map?
einpoklum
1

votes
2

answer
83

views

What is a good rule-of-thumb floating point comparison method selector?

I'm testing some bits of code, a number which involves computation using floating-point values - often very large numbers of these. I have some generic (C++-templated, but it doesn't really matter for the sake of this question) code which compares my outputs, be they scalar or arrays, against their...
einpoklum
1

votes
1

answer
262

views

Marking/labeling node-edge connection points with graphviz

With Graphviz, I know I can label edges and vertices. But what if I want to label some of the connections? That is, label some points where a specific edge meets a specific vertex? Is that possible? Notes: I don't care about beatuy/visual styles, I'll take something plain and dirty(ish) I would very...
einpoklum
1

votes
2

answer
91

views

Idiom for simulating run-time numeric template parameters?

Suppose we have template foo() { /* ... */ } defined. Now, I want to implement do_foo(unsigned n); which calls the corresponding variant of foo(). This is not merely a synthetic example - this does actually happen in real life (of course, not necessarily with void-to-void functions and just one te...
einpoklum
1

votes
2

answer
107

views

What are (empirically) sufficient conditions for NVCC to use ldg instead of normal loads?

Section G.4.2 of the CUDA C Programming Guide says: Data that is read-only for the entire lifetime of the kernel can also be cached in the read-only data cache described in the previous section by reading it using the __ldg() function ... When the compiler detects that the read-only condition is sat...
einpoklum
1

votes
1

answer
43

views

Make gcc -x somelang link with an arbitrary library file without -L'ing its directory?

I have a source file which is named foo.bar and for the purpose of this question cannot be renamed or linked to. Say it's a C++ source file. Now, I want to compile it and link it, in the same command, using a library at path/to/weird_lib_file. Now, if the source filename was foo.cpp, I could do: gcc...
einpoklum
1

votes
1

answer
436

views

In CMake, how do I add to a compiler flag only if it isn't used already?

I'm using CMake, and I want to add a compilation flag to some flags variable. For example, I want to add -DFOO to the CMAKE_CXX_FLAGS_RELEASE variable. Right now, I use: set(CMAKE_CXX_FLAGS_RELEASE '${CMAKE_CXX_FLAGS_RELEASE} -DFOO' ) ... but if there already is a -DFOO flag, I get it double, which...
einpoklum
1

votes
1

answer
228

views

Can I get CMake to generate Makefiles utilizing gcc incremental linking?

I've recently become aware of gcc's incremental linking feature, and I want to use it. The thing is, I don't write my own Makefile's - I use CMake. The inter-file dependencies and the targets are essentially the same, but I want to have CMake try to obtain them using incremental linking rather than...
einpoklum
1

votes
1

answer
172

views

How to deal with target name conflicts between Mercurial repositories and subrepositories?

My Mercurial repository repo1 has a custom target named foo; never mind what it does. I also have another repository repo2, which which I want to use as a subrepo of repo1. repo2 is developed in a similar fashion to repo1, and also has a custom target named foo, doing about the same thing (but just...
einpoklum
1

votes
1

answer
132

views

Does anything short of __syncthreads() prevent read-after-write intra-warp shared memory hazards?

I have a warp which writes some data to shared memory - with no overwrites, and soon after reads from shared memory. While there may be other warps in my block, they're not going to touch any part of that shared memory or write to anywhere my warp of interest reads from. Now, I recall that despite w...
einpoklum
1

votes
1

answer
307

views

What does CMAKE_BUILD_TYPE affect, other than the compiler flag selection?

I know that if if we set -DCMAKE_BUILD_TYPE=Release (or Debug etc.), then the values of CMAKE_C_FLAGS_RELEASE and CMAKE_CXX_FLAGS_RELEASE will be appended to CMAKE_C_FLAGS and CMAKE_C_FLAGS respectively. But is this the only effect of setting the build type? If not, what are the other effects?
einpoklum
1

votes
1

answer
156

views

Do modern nVIDIA GPUs perform sub-warp scheduling of work?

In recent nVIDIA GPU uarchitectures, a single streaming multiprocessor seems to be broken up into 4 sub-units; with each of them having horizontal or vertical 'bars' of 8 'squares', corresponding to different functional units: integer ops, 32-bit flops, 64-bit flops, and load/store. A single warp sc...
einpoklum
1

votes
1

answer
45

views

What are the MonetDB equivalents of MySQL's least() and greatest()?

SQL queries reserve the names min() and max() for aggregate functions, leaving DBMSes to make other choices for scalar functions of the same functionality - the minimum or maximum value from a fixed-length list of arguments. MySQL uses least() and greatest(), respectively, for that purpose; what are...
einpoklum

View additional