From ab023c27a374bb69bd7300b5b6f0789844fc8ba9 Mon Sep 17 00:00:00 2001 From: Francisco Jerez Date: Sat, 14 Jun 2014 20:53:35 +0200 Subject: [PATCH] clover: Optimize module serialization for vectors of fundamental types. Tested-by: Tom Stellard --- .../state_trackers/clover/core/module.cpp | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/clover/core/module.cpp b/src/gallium/state_trackers/clover/core/module.cpp index 3e3ad99e450..41de7344203 100644 --- a/src/gallium/state_trackers/clover/core/module.cpp +++ b/src/gallium/state_trackers/clover/core/module.cpp @@ -69,7 +69,9 @@ namespace { /// (De)serialize a vector. template - struct _serializer> { + struct _serializer, + typename std::enable_if< + !std::is_scalar::value>::type> { static void proc(compat::ostream &os, const compat::vector &v) { _proc(os, v.size()); @@ -87,6 +89,25 @@ namespace { } }; + template + struct _serializer, + typename std::enable_if< + std::is_scalar::value>::type> { + static void + proc(compat::ostream &os, const compat::vector &v) { + _proc(os, v.size()); + os.write(reinterpret_cast(v.begin()), + v.size() * sizeof(T)); + } + + static void + proc(compat::istream &is, compat::vector &v) { + v.reserve(_proc(is)); + is.read(reinterpret_cast(v.begin()), + v.size() * sizeof(T)); + } + }; + /// (De)serialize a module::section. template<> struct _serializer { -- 2.30.2