Skip to content

Commit f35b2e6

Browse files
Change DPCTLPlatformMgr_PrintInfo function to return char *
1 parent a20344b commit f35b2e6

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

dpctl/_backend.pxd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ cdef extern from "syclinterface/dpctl_sycl_platform_manager.h":
262262
cdef DPCTLSyclPlatformRef DPCTLPlatformVector_GetAt(
263263
DPCTLPlatformVectorRef,
264264
size_t index)
265-
cdef void DPCTLPlatformMgr_PrintInfo(const DPCTLSyclPlatformRef, size_t)
265+
cdef const char *DPCTLPlatformMgr_PrintInfo(const DPCTLSyclPlatformRef, size_t)
266266

267267

268268
cdef extern from "syclinterface/dpctl_sycl_platform_interface.h":

libsyclinterface/include/dpctl_sycl_platform_manager.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ DPCTL_DECLARE_VECTOR(Platform)
6161
* printed out.
6262
*/
6363
DPCTL_API
64-
void DPCTLPlatformMgr_PrintInfo(__dpctl_keep const DPCTLSyclPlatformRef PRef,
65-
size_t verbosity);
64+
__dpctl_give const char *
65+
DPCTLPlatformMgr_PrintInfo(__dpctl_keep const DPCTLSyclPlatformRef PRef,
66+
size_t verbosity);
6667

6768
/*! @} */
6869

libsyclinterface/source/dpctl_sycl_platform_manager.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "dpctl_sycl_platform_manager.h"
2828
#include "Support/CBindingWrapping.h"
2929
#include "dpctl_error_handlers.h"
30+
#include "dpctl_string_utils.hpp"
3031
#include "dpctl_sycl_platform_interface.h"
3132
#include "dpctl_utils_helper.h"
3233
#include <CL/sycl.hpp>
@@ -41,7 +42,7 @@ namespace
4142
{
4243
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(platform, DPCTLSyclPlatformRef);
4344

44-
void platform_print_info_impl(const platform &p, size_t verbosity)
45+
std::string platform_print_info_impl(const platform &p, size_t verbosity)
4546
{
4647
std::stringstream ss;
4748

@@ -96,7 +97,7 @@ void platform_print_info_impl(const platform &p, size_t verbosity)
9697
}
9798
}
9899

99-
std::cout << ss.str();
100+
return ss.str();
100101
}
101102

102103
} // namespace
@@ -106,15 +107,19 @@ void platform_print_info_impl(const platform &p, size_t verbosity)
106107
#include "dpctl_vector_templ.cpp"
107108
#undef EL
108109

109-
void DPCTLPlatformMgr_PrintInfo(__dpctl_keep const DPCTLSyclPlatformRef PRef,
110-
size_t verbosity)
110+
__dpctl_give const char *
111+
DPCTLPlatformMgr_PrintInfo(__dpctl_keep const DPCTLSyclPlatformRef PRef,
112+
size_t verbosity)
111113
{
114+
const char *cstr_info = nullptr;
112115
auto p = unwrap(PRef);
113116
if (p) {
114-
platform_print_info_impl(*p, verbosity);
117+
auto infostr = platform_print_info_impl(*p, verbosity);
118+
cstr_info = dpctl::helper::cstring_from_string(infostr);
115119
}
116120
else {
117121
error_handler("Platform reference is NULL.", __FILE__, __func__,
118122
__LINE__);
119123
}
124+
return cstr_info;
120125
}

0 commit comments

Comments
 (0)