Skip to content

Commit f85ebea

Browse files
almost done with qthreads addition, need to dad better preemption, adding process/thread/pool selector at same time
1 parent 336f300 commit f85ebea

File tree

5 files changed

+229
-0
lines changed

5 files changed

+229
-0
lines changed

raftinc/kpair.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "kset.tcc"
2525
#include "portorder.hpp"
2626
#include "defs.hpp"
27+
#include "raftmanip.hpp"
2728

2829
namespace raft
2930
{
@@ -135,6 +136,9 @@ ROoOkpair& operator >> ( kpair &a, const raft::order::spec &&order );
135136
kpair& operator >> ( ROoOkpair &a, raft::kernel &b );
136137
kpair& operator >> ( ROoOkpair &a, raft::kernel &&b );
137138

139+
kpair& operator >> ( kpair &a, const raft::parallel::type &&type );
140+
kpair& operator >> ( raft::kernel &a, const raft::parallel::type &&type );
141+
138142
kpair& operator <= ( raft::kernel &a, raft::kernel &b );
139143
kpair& operator <= ( raft::kernel &&a, raft::kernel &&b );
140144
kpair& operator <= ( raft::kernel &a, kpair &b );

raftinc/raftmanip.hpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* raftmanip.hpp -
3+
* @author: Jonathan Beard
4+
* @version: Tue Aug 16 09:56:56 2016
5+
*
6+
* Copyright 2016 Jonathan Beard
7+
*
8+
* Licensed under the Apache License, Version 2.0 (the "License");
9+
* you may not use this file except in compliance with the License.
10+
* You may obtain a copy of the License at:
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
#ifndef _RAFTMANIP_HPP_
21+
#define _RAFTMANIP_HPP_ 1
22+
23+
namespace raft
24+
{
25+
namespace parallel
26+
{
27+
enum type { thread /** specify a thread for each kernel **/,
28+
pool /** thread pool, one kernel thread per core, many kernels in each **/,
29+
process /** open a new process from this point **/ };
30+
}
31+
namespace vm
32+
{
33+
enum type { flat /** not yet implemented **/,
34+
standard /** threads share VM space, processes have sep **/,
35+
partition /** partition graph at this point into a new VM space, platform dependent **/ };
36+
}
37+
} /** end namespace raft **/
38+
39+
#endif /* END _RAFTMANIP_HPP_ */

raftmanip

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* raftmanip.hpp -
3+
* @author: Jonathan Beard
4+
* @version: Tue Aug 16 10:12:22 2016
5+
*
6+
* Copyright 2016 Jonathan Beard
7+
*
8+
* Licensed under the Apache License, Version 2.0 (the "License");
9+
* you may not use this file except in compliance with the License.
10+
* You may obtain a copy of the License at:
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
#ifndef _RAFTMANIP_HPP_
21+
#define _RAFTMANIP_HPP_ 1
22+
23+
#include ./raftinc/raftmanip.hpp
24+
25+
#endif /* END _RAFTMANIP_HPP_ */

src/kpair.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,20 @@ operator >> ( ROoOkpair &a, raft::kernel &&b )
182182
return( *ptr );
183183
}
184184

185+
//FIXME
186+
kpair&
187+
operator >> ( kpair &a, const raft::parallel::type &&type )
188+
{
189+
kpair *ptr( nullptr );
190+
return( *ptr );
191+
}
192+
193+
kpair&
194+
operator >> ( raft::kernel &a, const raft::parallel::type &&type )
195+
{
196+
197+
}
198+
185199

186200
kpair&
187201
operator <= ( raft::kernel &a, raft::kernel &b )

testsuite/poolThreadRaftManip.cpp

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
/**
2+
* allocateSendPush.cpp - throw an error if internal object
3+
* pop fails.
4+
*
5+
* @author: Jonathan Beard
6+
* @version: Sat Feb 27 19:10:26 2016
7+
*
8+
* Copyright 2016 Jonathan Beard
9+
*
10+
* Licensed under the Apache License, Version 2.0 (the "License");
11+
* you may not use this file except in compliance with the License.
12+
* You may obtain a copy of the License at:
13+
*
14+
* http://www.apache.org/licenses/LICENSE-2.0
15+
*
16+
* Unless required by applicable law or agreed to in writing, software
17+
* distributed under the License is distributed on an "AS IS" BASIS,
18+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19+
* See the License for the specific language governing permissions and
20+
* limitations under the License.
21+
*/
22+
#include <cstdint>
23+
#include <cstdio>
24+
#include <cstddef>
25+
#include <raft>
26+
#include <raftmanip>
27+
#include <cstdlib>
28+
#include <cassert>
29+
30+
31+
template < std::size_t N > struct foo
32+
{
33+
foo() : length( N ){}
34+
35+
foo( const foo &other ) : length( other.length )
36+
{
37+
using index_type = std::remove_const_t<decltype(N)>;
38+
for( index_type i( 0 ); i < N; i++ )
39+
{
40+
pad[ i ] = other.pad[ i ];
41+
}
42+
}
43+
44+
~foo() = default;
45+
46+
int length;
47+
int pad[ N ];
48+
};
49+
50+
using obj_t = foo< 80 >;
51+
52+
class start : public raft::kernel
53+
{
54+
public:
55+
start() : raft::kernel()
56+
{
57+
output.addPort< obj_t >( "y" );
58+
}
59+
60+
virtual ~start() = default;
61+
62+
virtual raft::kstatus run()
63+
{
64+
auto &mem( output[ "y" ].allocate< obj_t >() );
65+
for( auto i( 0 ); i < mem.length; i++ )
66+
{
67+
mem.pad[ i ] = static_cast< int >( counter );
68+
}
69+
output[ "y" ].send();
70+
counter++;
71+
if( counter == 200 )
72+
{
73+
return( raft::stop );
74+
}
75+
return( raft::proceed );
76+
}
77+
78+
private:
79+
std::size_t counter = 0;
80+
};
81+
82+
83+
class middle : public raft::kernel
84+
{
85+
public:
86+
middle() : raft::kernel()
87+
{
88+
input.addPort< obj_t >( "x" );
89+
output.addPort< obj_t >( "y" );
90+
}
91+
92+
virtual raft::kstatus run()
93+
{
94+
auto &val( input[ "x" ].peek< obj_t >() );
95+
output[ "y" ].push( val );
96+
input[ "x" ].unpeek();
97+
input[ "x" ].recycle( 1 );
98+
return( raft::proceed );
99+
}
100+
};
101+
102+
103+
class last : public raft::kernel
104+
{
105+
public:
106+
last() : raft::kernel()
107+
{
108+
input.addPort< obj_t >( "x" );
109+
}
110+
111+
virtual ~last() = default;
112+
113+
virtual raft::kstatus run()
114+
{
115+
obj_t mem;
116+
input[ "x" ].pop( mem );
117+
/** Jan 2016 - otherwise end up with a signed/unsigned compare w/auto **/
118+
using index_type = std::remove_const_t< decltype( mem.length ) >;
119+
for( index_type i( 0 ); i < mem.length; i++ )
120+
{
121+
//will fail if we've messed something up
122+
if( static_cast< std::size_t >( mem.pad[ i ] ) != counter )
123+
{
124+
std::cerr << "failed test\n";
125+
exit( EXIT_FAILURE );
126+
}
127+
}
128+
counter++;
129+
return( raft::proceed );
130+
}
131+
132+
private:
133+
std::size_t counter = 0;
134+
};
135+
136+
int
137+
main()
138+
{
139+
start s;
140+
last l;
141+
middle m;
142+
143+
raft::map M;
144+
M += s >> m >> raft::parallel::thread >> l;
145+
M.exe();
146+
return( EXIT_SUCCESS );
147+
}

0 commit comments

Comments
 (0)