Software Archive
Read-only legacy content
17060 Discussions

Issues using virtual shared memory with STL

Yu_Dong_Y_
Beginner
741 Views

Hi, 

I ran into two issues trying  host offload mode using STL + virtual shared memory.

Please check the attache shm.cpp.

There are two issues:

1.  intel's implementation of __offload::shared_allocator is not fully compatible with std::allocator, missing a few operators, eg: ==.  Please refer to GCC's correspondent header.

2. How to declare an iterator in this case ?   The situation looks to be conflicting

The following is output of icc:

icc -o shm shm.cpp
shm.cpp(31): error: illegal to declare an object of a class not marked _Cilk_shared, in a _Cilk_shared context
     shared_map::iterator it;
                          ^

shm.cpp(32): warning #2697: _Cilk_shared may not be applied to local variables
     shared_map::iterator my_declare_shared  it2;
                                             ^

shm.cpp(33): warning #2697: _Cilk_shared may not be applied to local variables
     my_declare_shared shared_map::iterator  it3;
                                             ^

/usr/include/c++/4.4.6/bits/basic_string.h(220): error: no operator "==" matches these operands
            operand types are: const __offload::shared_allocator<char> == const __offload::shared_allocator<char>
          return (!_M_is_leaked() && __alloc1 == __alloc2)
                                              ^
          detected during:
            instantiation of "_CharT *std::basic_string<_CharT, _Traits, _Alloc>::_Rep::_M_grab(const _Alloc &, const _Alloc &) [with _CharT=char, _Traits=std::char_traits<char>, _Alloc=__offload::shared_allocator<char>]" at line 172 of "/usr/include/c++/4.4.6/bits/basic_string.tcc"
            instantiation of "std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const std::basic_string<_CharT, _Traits, _Alloc> &) [with _CharT=char, _Traits=std::char_traits<char>, _Alloc=__offload::shared_allocator<char>]" at line 84 of "/usr/include/c++/4.4.6/bits/stl_pair.h"
            instantiation of "std::pair<_T1, _T2>::pair(const _T1 &, const _T2 &) [with _T1=const char, _T2=shared_string]" at line 450 of "/usr/include/c++/4.4.6/bits/stl_map.h"
            instantiation of "std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type &std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const std::map<_Key, _Tp, _Compare, _Alloc>::key_type &) [with _Key=char, _Tp=shared_string, _Compare=std::less<char>, _Alloc=__offload::shared_allocator<std::pair<const char, shared_string>>]" at line 51 of "shm.cpp"

compilation aborted for shm.cpp (code 2)

0 Kudos
0 Replies
Reply