Skip to content

Commit 5900ab3

Browse files
committed
opencl configure, cpp file to memory
1 parent 3ebe66f commit 5900ab3

5 files changed

Lines changed: 69 additions & 16 deletions

File tree

‎cpp/common.hpp‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,18 @@
8080
#include <cstring>
8181

8282
// Keeps a list of functions that called it for testing purposes.
83-
static std::vector<std::string> callStack;
84-
static void printCallStack() {
83+
std::vector<std::string> callStack;
84+
void printCallStack() {
8585
std::cout << "callStack:" << std::endl;
8686
for (auto& s : callStack)
8787
std::cout << s << std::endl;
8888
std::cout << "END callStack" << std::endl;
8989
}
9090

9191
// Global thread parameters.
92-
static const int NUM_THREADS = 1000;
93-
static const int NUM_ITERS = 1000;
94-
static const int NUM_OPS = NUM_THREADS * NUM_ITERS;
92+
const int NUM_THREADS = 1000;
93+
const int NUM_ITERS = 1000;
94+
const int NUM_OPS = NUM_THREADS * NUM_ITERS;
9595

9696
// Misc.
97-
static bool odd(int i){ return (i % 2) == 1; }
97+
bool odd(int i){ return (i % 2) == 1; }

‎cpp/file_io.cpp‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,20 +205,16 @@ int main() {
205205
std::string path("i_dont_exist.tmp");
206206
std::ifstream ifs(path);
207207
if (ifs) {
208+
assert(false);
208209
} else {
209210
try {
210-
throw std::ios_base::failure("Error: Could not write to file: " + path);
211+
//throw std::ios_base::failure("Error: Could not write to file: " + path);
211212
} catch (std::ios_base::failure e) {
212213
std::clog << e.what() << std::endl;
213214
}
214-
215215
}
216216
}
217217

218-
/
219-
{
220-
}
221-
222218
// # ios::in: flag automatically set for ifstream, but not fstream
223219
//http://stackoverflow.com/questions/7463410/is-iosin-needed-for-ifstreams-opened-in-binary-mode
224220
}

‎cpp/file_to_memory.cpp‎

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
http://stackoverflow.com/questions/539537/how-to-write-to-a-memory-buffer-with-a-file
3+
*/
4+
5+
#include <cassert>
6+
#include <cstring>
7+
#include <fstream>
8+
#include <iostream>
9+
#include <ostream>
10+
#include <sstream>
11+
12+
template <typename char_type>
13+
struct ostreambuf : public std::basic_streambuf<char_type, std::char_traits<char_type> > {
14+
ostreambuf(char_type* buffer, std::streamsize bufferLength) {
15+
this->setp(buffer, buffer + bufferLength);
16+
}
17+
};
18+
19+
void write(std::ostream& os) {
20+
os << "abc";
21+
}
22+
23+
int main() {
24+
/* To memory, in our own externally supplied buffer. */
25+
{
26+
char c[3];
27+
ostreambuf<char> buf(c, sizeof(c));
28+
std::ostream s(&buf);
29+
write(s);
30+
assert(memcmp(c, "abc", sizeof(c)) == 0);
31+
}
32+
33+
/* To memory, but in a hidden buffer. */
34+
{
35+
std::stringstream s;
36+
write(s);
37+
assert(s.str() == "abc");
38+
}
39+
40+
/* To file. */
41+
{
42+
std::ofstream s("a.tmp");
43+
write(s);
44+
s.close();
45+
}
46+
47+
/* I think this is implementation defined.
48+
* pusetbuf calls basic_filebuf::setbuf(). */
49+
{
50+
char c[3];
51+
std::ofstream s;
52+
s.rdbuf()->pubsetbuf(c, sizeof c);
53+
write(s);
54+
s.close();
55+
//assert(memcmp(c, "abc", sizeof(c)) == 0);
56+
}
57+
}

‎opencl/configure‎

100644100755
File mode changed.

‎opengl/benchmarks.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
Since the raison d'etre of OpenGL is to have high performance, you will want to know how your application performs compared to some standardized benchmarks.
44

5-
- <http://askubuntu.com/questions/31913/how-to-perform-a-detailed-and-quick-3d-performance-test>
5+
<http://askubuntu.com/questions/31913/how-to-perform-a-detailed-and-quick-3d-performance-test>
66

77
Free:
88

9-
- `glxgears`. `es2gears` from Ubuntu 16.04 `mesa-utils-extra` is an GLES2 implementation.
10-
- `glmark2`. Maintained by Linaro.
11-
- `phoronix`
9+
- `glxgears`. `es2gears` from Ubuntu 16.04 `mesa-utils-extra` is an GLES2 implementation. Disable vsync: <http://stackoverflow.com/questions/17196117/disable-vertical-sync-for-glxgears>
10+
- `glmark2`. Maintained by Linaro. TODO how is the score calculated? <https://github.com/glmark2/glmark2/issues/31>
11+
- `phoronix-test-suite`. Usage: <http://askubuntu.com/questions/31913/how-to-perform-a-detailed-and-quick-3d-performance-test/820264#820264>
1212

1313
Non free:
1414

0 commit comments

Comments
 (0)