Skip to content

Commit 7b7e426

Browse files
committed
Remove iostream.
1 parent f96cd5e commit 7b7e426

23 files changed

+17
-40
lines changed

src/api/c/device.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <af/device.h>
1212
#include <backend.hpp>
1313
#include <platform.hpp>
14-
#include <iostream>
1514
#include <Array.hpp>
1615
#include <handle.hpp>
1716
#include <memory.hpp>
@@ -33,7 +32,7 @@ af_err af_init()
3332

3433
af_err af_info()
3534
{
36-
std::cout << getInfo();
35+
printf("%s", getInfo().c_str());
3736
return AF_SUCCESS;
3837
}
3938

@@ -73,10 +72,8 @@ af_err af_get_device(int *device)
7372
af_err af_set_device(const int device)
7473
{
7574
try {
76-
if (setDevice(device) < 0) {
77-
std::cout << "Invalid Device ID" << std::endl;
78-
return AF_ERR_INVALID_ARG;
79-
}
75+
ARG_ASSERT(0, device >= 0);
76+
ARG_ASSERT(0, setDevice(device) >= 0);
8077
} CATCHALL;
8178

8279
return AF_SUCCESS;

src/api/c/dim4.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <numeric>
1212
#include <cmath>
1313
#include <vector>
14-
#include <iostream>
1514
#include <af/dim4.hpp>
1615
#include <ArrayInfo.hpp>
1716
#include <err_common.hpp>

src/api/c/err_common.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@
1010
#include <err_common.hpp>
1111
#include <type_util.hpp>
1212
#include <string>
13-
#include <iostream>
1413
#include <sstream>
1514
#include <cstring>
15+
#include <cstdio>
1616

1717
using std::string;
1818
using std::stringstream;
19-
using std::cerr;
2019

2120
AfError::AfError(const char * const funcName,
2221
const int line,
@@ -135,7 +134,7 @@ print_error(const stringstream &msg)
135134
const char* perr = getenv("AF_PRINT_ERRORS");
136135
if(perr != nullptr) {
137136
if(std::strncmp(perr, "0", 1) != 0)
138-
cerr << msg.str() << std::endl;
137+
fprintf(stderr, "%s\n", msg.str().c_str());
139138
}
140139
}
141140

src/api/c/imageio.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include <memory.hpp>
2424

2525
#include <FreeImage.h>
26-
#include <iostream>
2726
#include <string>
2827
#include <cstring>
2928
#include <cstdio>

src/api/cpp/util.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@
99

1010
#include <af/array.h>
1111
#include <af/util.h>
12-
#include <iostream>
1312
#include "error.hpp"
13+
#include <cstdio>
1414

1515
using namespace std;
1616

1717
namespace af
1818
{
1919
void print(const char *exp, const array &arr)
2020
{
21-
std::cout << exp << " ";
21+
printf("%s ", exp);
2222
AF_THROW(af_print_array(arr.get()));
2323
return;
2424
}

src/backend/cpu/Array.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include <af/dim4.hpp>
1111
#include <Array.hpp>
1212
#include <copy.hpp>
13-
#include <iostream>
1413
#include <TNJ/BufferNode.hpp>
1514
#include <TNJ/ScalarNode.hpp>
1615
#include <memory.hpp>

src/backend/cpu/blas.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include <blas.hpp>
1111
#include <af/dim4.hpp>
1212
#include <handle.hpp>
13-
#include <iostream>
1413
#include <cassert>
1514
#include <err_cpu.hpp>
1615
#include <err_common.hpp>
@@ -121,7 +120,6 @@ toCblasTranspose(af_blas_transpose opt)
121120
return out;
122121
}
123122

124-
#include <iostream>
125123
using namespace std;
126124

127125

src/backend/cpu/iota.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include <algorithm>
1616
#include <numeric>
1717

18-
#include <iostream>
1918
using namespace std;
2019

2120
namespace cpu

src/backend/cpu/platform.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,8 @@
99

1010
#include <af/version.h>
1111
#include <platform.hpp>
12-
#include <iostream>
1312
#include <sstream>
1413

15-
using namespace std;
16-
1714
namespace cpu {
1815
static const char *get_system(void)
1916
{
@@ -33,9 +30,9 @@ namespace cpu {
3330
#endif
3431
}
3532

36-
string getInfo()
33+
std::string getInfo()
3734
{
38-
ostringstream info;
35+
std::ostringstream info;
3936
info << "ArrayFire v" << AF_VERSION
4037
<< " (CPU, " << get_system() << ", build " << AF_REVISION << ")" << std::endl;
4138
return info.str();
@@ -50,7 +47,7 @@ namespace cpu {
5047
{
5148
static bool flag;
5249
if(!flag) {
53-
std::cout << "WARNING: af_devprop not supported for CPU" << std::endl;
50+
printf("WARNING: af_devprop not supported for CPU\n");
5451
flag = 1;
5552
}
5653
}
@@ -64,7 +61,7 @@ namespace cpu {
6461
{
6562
static bool flag;
6663
if(!flag) {
67-
std::cout << "WARNING: af_set_device not supported for CPU" << std::endl;
64+
printf("WARNING: af_set_device not supported for CPU\n");
6865
flag = 1;
6966
}
7067
return 1;

src/backend/cuda/blas.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include <stdexcept>
1616
#include <string>
1717
#include <cassert>
18-
#include <iostream>
1918
#include <math.hpp>
2019
#include <err_common.hpp>
2120
#include <boost/scoped_ptr.hpp>
@@ -187,7 +186,8 @@ Array<T> matmul(const Array<T> &lhs, const Array<T> &rhs,
187186
&beta , out.get(), out.dims()[0]);
188187

189188
if(err != CUBLAS_STATUS_SUCCESS) {
190-
std::cout <<__PRETTY_FUNCTION__<< " ERROR: " << cublasErrorString(err) << std::endl;
189+
printf("%s ERROR: %s\n", __PRETTY_FUNCTION__ , cublasErrorString(err));
190+
//TODO: Throw Exception?
191191
}
192192
}
193193

0 commit comments

Comments
 (0)