インテル® スレッディング・ビルディング・ブロック・リファレンス・マニュアル

Size: px
Start display at page:

Download "インテル® スレッディング・ビルディング・ブロック・リファレンス・マニュアル"

Transcription

1 2007 Intel Corporation. : 1.6 Web :

2 Intel's Terms and Conditions of Sale MPEG /ISO MPEG MPEG Intel Corporation IntelIntel Itanium Intel Corporation * 2007 Intel Corporation Partitioner parallel_for parallel_reduce parallel_scan recycle_as_safe_continuation "" ii

3 CopyConstructible tbb tbb::internal TBB_DO_ASSERT TBB_DO_THREADING_TOOLS split Range blocked_range<value> size_type blocked_range( Value begin, Value end, size_t grainsize=1 ) blocked_range( blocked_range& range, split ) size_type size() const bool empty() const size_type grainsize() const bool is_divisible() const const_iterator begin() const const_iterator end() const...15 iii

4 3.2.2 blocked_range2d row_range_type col_range_type blocked_range2d<rowvalue,colvalue>( RowValue row_begin, RowValue row_end, typename row_range_type::size_type row_grainsize, ColValue col_begin, ColValue col_end, typename col_range_type::size_type col_grainsize ) blocked_range2d<rowvalue,colvalue> ( blocked_range2d& range, split ) bool empty() const bool is_divisible() const const row_range_type& rows() const const col_range_type& cols() const Partitioner simple_partitioner simple_partitioner() simple_partitioner(simple_partitioner &partitioner, split ) template<typename Range> bool should_execute_range (const Range &r, const task &t) auto_partitioner auto_partitioner() auto_partitioner(auto_partitioner &partitioner, split ) template<typename Range> bool should_execute_range (const Range &r, const task &t) parallel_for<range,body> Partitioner parallel_reduce<range,body> Partitioner parallel_scan<range,body> pre_scan_tag and final_scan_tag bool is_final_scan() Partitioner parallel_while parallel_while<body>() ~parallel_while<body>() <typename Stream> void run( Stream& stream, const Body& body ) void add( const value_type& item ) pipeline pipeline() ~pipeline() void add_filter( filter& f ) void run( size_t max_number_of_live_tokens ) void clear()...44 iv

5 3.8.6 filter filter( bool is_serial ) ~filter() bool is_serial() const virtual void* operator()( void * item ) parallel_sort<randomaccessiterator, Compare> concurrent_hash_map<key,t, HashCompare> concurrent_hash_map() concurrent_hash_map( const concurrent_hash_map& table ) ~concurrent_hash_map() concurrent_hash_map& operator= ( concurrent_hash_map& source ) void clear() const_accessor accessor bool find( const_accessor& result, const Key& key ) const bool find( accessor& result, const Key& key ) bool insert( const_accessor& result, const Key& key ) bool insert( accessor& result, const Key& key ) bool erase(const Key& key ) const_range_type range( size_t grainsize ) const range_type range( size_t grainsize ) size_type size() const bool empty() const size_type max_size() const iterator begin() iterator end() const_iterator begin() const const_iterator end() const concurrent_queue<t> concurrent_queue() ~concurrent_queue() void push( const T& source ) void pop( T& destination ) bool pop_if_present( T& destination ) size_type size() const bool empty() const size_type capacity() const void set_capacity( size_type capacity )...63 v

6 iterator begin() iterator end() const_iterator begin() const const_iterator end() const concurrent_vector concurrent_vector() concurrent_vector( const concurrent_vector& src ) concurrent_vector& operator=( const concurrent_vector& src ) ~concurrent_vector() void clear() size_type grow_by( size_type delta ) void grow_to_at_least( size_type n ) size_t push_back( const_reference value ); reference operator[]( size_type index ) const_reference operator[]( size_type index ) const; range_type range( size_t grainsize ) const_range_type range( size_t grainsize ) const size_type size() const bool empty() const size_type capacity() const void reserve( size_type n ) size_type max_size() const iterator begin() iterator end() const_iterator begin() const const_iterator end() const iterator rbegin() iterator rend() const_reverse_iterator rbegin() const const_ reverse_iterator rend() const Allocator scalable_allocator<t> C cache_aligned_allocator<t> pointer allocate( size_type n, void* hint=0 ) void deallocate( pointer p, size_type n ) char* _Charalloc( size_type size ) aligned_space...78 vi

7 5.4.1 aligned_space() ~aligned_space() T* begin() T* end() Mutex Mutex mutex spin_mutex queuing_mutex ReaderWriterMutex ReaderWriterMutex() ~ReaderWriterMutex() ReaderWriterMutex::scoped_lock() ReaderWriterMutex::scoped_lock( ReaderWriterMutex& rw, bool write =true) ReaderWriterMutex::~scoped_lock() void ReaderWriterMutex:: scoped_lock:: acquire( ReaderWriterMutex& rw, bool write=true ) bool ReaderWriterMutex:: scoped_lock::try_acquire( ReaderWriterMutex& rw, bool write=true ) void ReaderWriterMutex:: scoped_lock::release() bool ReaderWriterMutex:: scoped_lock::upgrade_to_writer() bool ReaderWriterMutex:: scoped_lock::downgrade_to_reader() spin_rw_mutex queuing_rw_mutex atomic<t> enum memory_semantics value_type fetch_and_add( value_type addend ) value_type fetch_and_increment() value_type fetch_and_decrement() value_type compare_and_swap value_type fetch_and_store( value_type new_value ) tick_count static tick_count tick_count::now() tick_count::interval_t operator ( const tick_count& t1, const tick_count& t0 ) tick_count::interval_t interval_t() double seconds() const interval_t operator+=( const interval_t& i ) interval_t operator =( const interval_t& i ) interval_t operator+ ( const interval_t& i, const interval_t& j ) interval_t operator ( const interval_t& i, const interval_t& j )...96 vii

8 task_scheduler_init task_scheduler_init( int number_of_threads=automatic ) ~task_scheduler_init() void initialize( int number_of_threads=automatic ) void terminate() OpenMP task execute() new( task::allocate_root() ) T new( this. allocate_continuation() ) T new( this. allocate_child() ) T new( this.task::allocate_additional_child_of( parent )) void destroy( task& victim ) void recycle_as_continuation() void recycle_as_safe_continuation() void recycle_as_child_of( task& parent ) void recycle _to_reexecute() depth_type depth_type depth() const void set_depth( depth_type new_depth ) void add_to_depth( int delta ) void set_ref_count( int count ) void wait_for_all() void spawn( task& child ) void spawn ( task_list& list ) void spawn_and_wait_for_all( task& child ) void spawn_and_wait_for_all( task_list& list ) static void spawn_root_and_wait( task& root ) static void spawn_root_and_wait( task_list& root_list ) static task& self() task* parent() const bool is_stolen_task() const state_type state() const int ref_count() const viii

9 8.4 empty_task task_list task_list() ~task_list() bool empty() const push_back( task& task ) task& task pop_front() void clear() k k ix

10

11 1 ISO C++ C++ (STL) : 1

12 2 2.1 Courier blocked_range<type> blocked_range Type Type blocked_range<int> Foo class Foo { public: int x(); int y; ~Foo(); }; class FooBase { protected: int x(); }; class Foo: protected FooBase { private: int internal_stuff; public: using FooBase::x; int y; }; 2 x() protected 2

13 (concept) "sortable" T x < y T swap(x,y) x y C ISO C++ 1 T 1: "sortable" bool operator<(const T& x, const T& y) void swap(t& x, T& y) x y x y 1 Concepts for C++0x (

14 C++ int bool U (const U&) U 1 operator< int operator<( U x, U y ) C++ const bool operator<( U& x, U& y ) int x y swap(x,y) int 1 x<y int operator< CopyConstructible ISO C++ CopyConstructible 2 CopyConstructible 2: CopyConstructible T( const T& ) const T ~T() T* operator&() const T* operator&() const const T ISO C++ underscore_style () PascalCase 4

15 2.3.2 TBB tbb tbb tbb::internal tbb::internal tbb::internal typedef concurrent_vector<t>::iterator internal::vector_iterator<container,value> typedef iterator typedef

16 TBB_DO_ASSERT TBB_DO_ASSERT TBB_DO_ASSERT 1 stderr C abort tbb::assertion_failure : Windows* TBB_DO_ASSERT TBB_DO_THREADING_TOOLS TBB_DO_THREADING_TOOLS TBB_DO_THREADING_TOOLS 1 TBB_DO_THREADING_TOOLS 0 spin_mutex (6.1.3) spin_rw_mutex (6.1.6) 6

17 x X 3: X::X(X& x, Split) x x 2 Split x x () 2 7

18 blocked_range (3.2.1) blocked_range2d (3.2.2) 2 blocked_range<value> parallel_reduce (3.5) parallel_scan (3.6) split class split; #include "tbb/tbb_stddef.h" split namespace tbb { class split { }; } 3.2 Range 8

19 4 Range R 4: Range R::R( const R& ) R::~R() bool R::empty() const bool R::is_divisible() const true 2 true R::R( R& r, split ) r 2 Range 2 Range Range blocked_range (3.2.1) grainsize 2 parallel_for (3.4) parallel_reduce (3.5) parallel_scan (3.6) Range TrivialIntegerRange (lower,upper) 9

20 struct TrivialIntegerRange { int lower; int upper; bool empty() const {return lower==upper;} bool is_divisible() const {return upper>lower+1;} TrivialIntegerRange( TrivialIntegerRange& r, split ) { int m = (r.lower+r.upper)/2; lower = m; upper = r.upper; r.upper = m; } }; TrivialIntegerRange blocked_range blocked_range (3.2.1) 1 blocked_range2d (3.2.2) blocked_range<value> template<typename Value> class blocked_range; #include "tbb/blocked_range.h" blocked_range<value> [i,j) i j 5 2 int size_t blocked_range<int> Value size_t STL 10

21 blocked_range Range (3.2) 5: blocked_range Value Value::Value( const Value& ) Value::~Value() bool operator<( const Value& i, const Value& j ) size_t operator ( const Value& i, const Value& j ) i j [i,j) Value operator+( const Value& i, size_t k ) i k blocked_range<value> size_t grainsize grainsize blocked_range 2 parallel_for parallel_reduce parallel_scan blocked_range<value> 1 2 grainsize 1. 10, % : blocked_range [i,j) j<i j<i parallel_for (3.4) parallel_reduce (3.5) parallel_scan (3.6) ( Value index=i; index<j; ++index )... 11

22 TBB_DO_ASSERT (2.6.1) blocked_range<value> parallel_for (3.4) parallel_reduce (3.5) parallel_scan (3.6) namespace tbb { template<typename Value> class blocked_range { public: // types typedef size_t size_type; typedef Value const_iterator; // constructors blocked_range( Value begin, Value end, size_type grainsize=1); blocked_range( blocked_range& r, split ); // capacity size_type size() const; bool empty() const; // access size_type grainsize() const; bool is_divisible() const; } }; // iterators const_iterator begin() const; const_iterator end() const; size_type blocked_range size_t const_iterator 12

23 const_iterator STL 5 Value const_iterator blocked_range STL const_iterator blocked_range( Value begin, Value end, size_t grainsize=1 ) grainsize grainsize (begin,end) blocked_range "blocked_range<int> r( 5, 14, 2 );" int r.begin()==5 r.end()== blocked_range( blocked_range& range, split ) is_divisible() true range 2 blocked_range range range range grainsize i j (i,j) g blocked_range<int> r(i,j,g) g (i,j) blocked_range<int> 13

24 blocked_range<int> s(r,split); g r (i, i +(j i)/2) s (i +(j i)/2, j) size_type size() const end()<begin() false end() begin() bool empty() const!(begin()<end()) size_type grainsize() const bool is_divisible() const!(end()<begin()) 14

25 size()>grainsize() true false const_iterator begin() const const_iterator end() const blocked_range2d 2 template<typename RowValue, typename ColValue> class blocked_range2d; #include "tbb/blocked_range2d.h" blocked_range2d<rowvalue,colvalue> 2 (i0,j0) (i1,j1) RowValue ColValue 5 blocked_range blocked_range Range (3.2) namespace tbb { template<typename RowValue, typename ColValue=RowValue> class blocked_range2d { 15

26 public: // Types typedef blocked_range<rowvalue> row_range_type; typedef blocked_range<colvalue> col_range_type; // Constructors blocked_range2d( RowValue row_begin, RowValue row_end, typename row_range_type::size_type row_grainsize, ColValue col_begin, ColValue col_end, typename col_range_type::size_type col_grainsize); blocked_range2d( blocked_range2d& r, split ); // Capacity bool empty() const; } }; // Access bool is_divisible() const; const row_range_type& rows() const; const col_range_type& cols() const; blocked_range2d const size_t L = 150; const size_t M = 225; const size_t N = 300; void SerialMatrixMultiply( float c[m][n], float a[m][l], float b[l][n] ) { for( size_t i=0; i<m; ++i ) { for( size_t j=0; j<n; ++j ) { float sum = 0; for( size_t k=0; k<l; ++k ) sum += a[i][k]*b[k][j]; c[i][j] = sum; } } } #include "tbb/parallel_for.h" #include "tbb/blocked_range2d.h" using namespace tbb; const size_t L = 150; const size_t M = 225; const size_t N = 300; 16

27 class MatrixMultiplyBody2D { float (*my_a)[l]; float (*my_b)[n]; float (*my_c)[n]; public: void operator()( const blocked_range2d<size_t>& r ) const { float (*a)[l] = my_a; float (*b)[n] = my_b; float (*c)[n] = my_c; for( size_t i=r.rows().begin(); i!=r.rows().end(); ++i ){ for( size_t j=r.cols().begin(); j!=r.cols().end(); ++j ) { float sum = 0; for( size_t k=0; k<l; ++k ) sum += a[i][k]*b[k][j]; c[i][j] = sum; } } } MatrixMultiplyBody2D( float c[m][n], float a[m][l], float b[l][n] ) : my_a(a), my_b(b), my_c(c) {} }; void ParallelMatrixMultiply(float c[m][n], float a[m][l], float b[l][n]){ parallel_for( blocked_range2d<size_t>(0, M, 16, 0, N, 32), MatrixMultiplyBody2D(c,a,b) ); } blocked_range2d 2 parallel_for blocked_range2d MatrixMultiplyBody2D::operator() row_range_type blocked_range<rowvalue> col_range_type blocked_range<colvalue> 17

28 blocked_range2d<rowvalue,colvalue>( RowValue row_begin, RowValue row_end, typename row_range_type::size_type row_grainsize, ColValue col_begin, ColValue col_end, typename col_range_type::size_type col_grainsize ) 2 blocked_range2d (row_begin,row_end) (col_begin,col_end) "blocked_range2d<char,int> r( a, z +1, 3, 0, 10, 2 );" (i, j) 2 i a z 3 j blocked_range2d<rowvalue,colvalue> ( blocked_range2d& range, split ) range 2 blocked_range2d range range range row_grainsize col_grainsize bool empty() const rows().empty() cols().empty() 18

29 bool is_divisible() const rows().is_divisible() cols().is_divisible() const row_range_type& rows() const const col_range_type& cols() const 3.3 Partitioner (3.2) 6 Partitioner P 6: Partitioner P::~P() template <typename Range> bool P::should_execute_range(const Range &r, const task &t) P::P( P& p, split ) r t true r false p 2 19

30 Partitioner parallel_for (3.4) parallel_reduce (3.5) parallel_scan (3.6) Range (3.2) is_divisible Partitioner Partitioner should_execute_range 2 Range Partitioner Range 2 Partitioner 2 Partitioner parallel_for parallel_reduce parallel_scan Partitioner should_execute_range should_execute_range true Partitioner simple_partitioner is_divisible false should_execute_range true class simple_partitioner { public: simple_partitioner() {} simple_partitioner(simple_partitioner &partitioner, split) {} template <typename Range> inline bool should_execute_range(const Range &r, const task &t) { return (!r.is_divisible() ); } }; 20

31 simple_partitioner (3.3.1) auto_partitioner (3.3.2) task_scheduler (8) simple_partitioner parallel_for (3.4) parallel_reduce (3.5) parallel_scan (3.6) class simple_partitioner; #include "tbb/partitioner.h" simple_partitioner parallel_for parallel_reduce parallel_scan simple_partitioner() simple_partitioner(simple_partitioner &partitioner, split ) template<typename Range> bool should_execute_range (const Range &r, const task &t) true!range.is_divisible() 21

32 3.3.2 auto_partitioner task_scheduler class auto_partitioner; #include "tbb/partitioner.h" auto_partitioner SI SI auto_partitioner auto_partitioner auto_partitioner auto_partitioner auto_partitioner() auto_partitioner(auto_partitioner &partitioner, split ) auto_partitioner 2 22

33 template<typename Range> bool should_execute_range (const Range &r, const task &t) true range.is_divisible() == true true range.is_divisible() == false true t r t r 3.4 parallel_for<range,body> template<typename Range, typename Body> void parallel_for ( const Range& range, const Body& body ); #include "tbb/parallel_for.h" parallel_for<range,body> Range Body Range Range (3.2) 7 7: parallel_for Body::Body( const Body& ) Body::~Body() void Body::operator()( Range& range ) const range 23

34 parallel_for is_divisible() false / Body::operator() parallel_for (8.2) parallel_for parallel_for parallel_for Range(r,split()) r r Body::operator() O(1) O(P log(n)) N P input[i-1] input[i] input[i+1] (0 i<n ) output[i] ParallelAverage #include "tbb/parallel_for.h" #include "tbb/blocked_range.h" using namespace tbb; struct Average { float* input; float* output; void operator()( const blocked_range<int>& range ) const { for( int i=range.begin(); i!=range.end(); ++i ) output[i] = (input[i-1]+input[i]+input[i+1])*(1/3.0f); } 24

35 }; // Note: The input must be padded such that input[-1] and input[n] // can be used to calculate the first and last output values. void ParallelAverage( float* output, float* input, size_t n ) { Average avg; avg.input = input; avg.output = output; parallel_for( blocked_range<int>( 0, n, 1000 ), avg ); } STL parallel_for (begin1,end1) 2 (begin2,end2) 3. m1 (begin1,end1) key 4. m2 key (begin2,end2) 5. (begin1,m1) (begin2,m2) 6. (m,end1) (m2,end2) 2 is_divisible #include "tbb/parallel_for.h" #include <algorithm> using namespace tbb; template<typename Iterator> struct ParallelMergeRange { static size_t grainsize; Iterator begin1, end1; merged Iterator begin2, end2; merged Iterator out; // [begin1,end1) is first sequence to be // [begin2,end2) is first sequence to be // where to put merged sequence 25

36 bool empty() const {return (end1-begin1)+(end2-begin2)==0;} bool is_divisible() { if( end1-begin1 < end2-begin2 ) { std::swap(begin1,begin2); std::swap(end1,end2); } // [begin2,end2) is now at least as short as [begin1,end1) return end2-begin2 > grainsize; } ParallelMergeRange( ParallelMergeRange& r, split ) { Iterator m1 = r.begin1 + (r.end1-r.begin1)/2; Iterator m2 = std::lower_bound( r.begin2, r.end2, *m1 ); begin1 = m1; begin2 = m2; end1 = r.end1; end2 = r.end2; out = r.out + (m1-r.begin1) + (m2-r.begin2); r.end1 = m1; r.end2 = m2; } ParallelMergeRange( Iterator begin1_, Iterator end1_, Iterator begin2_, Iterator end2_, Iterator out_ ) : begin1(begin1_), end1(end1_), begin2(begin2_), end2(end2_), out(out_) {} }; template<typename Iterator> size_t ParallelMergeRange<Iterator>::grainsize = 1000; template<typename Iterator> struct ParallelMergeBody { void operator()( ParallelMergeRange<Iterator>& r ) const { std::merge( r.begin1, r.end1, r.begin2, r.end2, r.out ); } }; template<typename Iterator> void ParallelMerge( Iterator begin1, Iterator end1, Iterator begin2, Iterator end2, Iterator out ) { parallel_for( ParallelMergeRange<Iterator>(begin1,end1,begin2,end2,out), ParallelMergeBody<Iterator>() ); } 26

37 3.4.1 Partitioner Partitioner template<typename Range, typename Body, typename Partitioner> void parallel_for ( const Range& range, const Body& body, const Partitioner &partitioner ); #include "tbb/parallel_for.h" parallel_for<range,body,partitioner> Range Body Range Range (3.2) 7 Partitioner Partitioner (3.3) parallel_for Partitioner auto_partitioner #include "tbb/parallel_for.h" #include "tbb/blocked_range.h" using namespace tbb; struct Average { float* input; float* output; void operator()( const blocked_range<int>& range ) const { for( int i=range.begin(); i!=range.end(); ++i ) output[i] = (input[i-1]+input[i]+input[i+1])*(1/3.0f); } }; // Note: The input must be padded such that input[-1] and input[n] // can be used to calculate the first and last output values. void ParallelAverage( float* output, float* input, size_t n ) { 27

38 } Average avg; avg.input = input; avg.output = output; parallel_for( blocked_range<int>( 0, n ), avg, auto_partitioner() ); 2 (1) parallel_for 3 auto_partitioner (2) blocked_range blocked_range blocked_range2d 1 8 simple_partitioner auto_partitioner 28

39 8: Partitioner Partitioner simple_partitioner Range::is_divisible blocked_range blocked_range2d ( ) auto_partitioner blocked_range blocked_range2d 1 : auto_partitioner () 3.5 parallel_reduce<range,body> template<typename Range, typename Body> void parallel_reduce( const Range& range, Body& body ); 29

40 #include "tbb/parallel_reduce.h" parallel_reduce<range,body> Range Body Range Range (3.2) Body 9 9: parallel_reduce Body Body::Body( Body&, split ); (3.1) operator() join Body::~Body() void Body::operator()( Range& range ); void Body::join( Body& rhs ); rhs this parallel_reduce is_divisible() false parallel_reduce 1 operator() join (8.2.1) parallel_reduce join this this rhs join op "left.join(right)" left left op right 1 parallel_reduce [0,20) b0 2 30

41 5 4 (/) (b1 b2) b0 b1 1 b2 [10,15) [15,20) parallel_reduce b0.join(b1) b0.join(b2) b 0 [0,20) b 0 [0,10) b 2 [10,20) b 0 [0,5) b 1 [5,10) b 2 [10,15) b 2 [15,20) 1: blocked_range<int>(0,20,5) parallel_reduce 1 1 b2 b2 b3 b0 join 1 1 b2 [10,15) [15,20) parallel_reduce parallel_reduce parallel_for (3.4) join O(1) O(P log(n)) N P #include "tbb/parallel_reduce.h" #include "tbb/blocked_range.h" using namespace tbb; 31

42 struct Sum { float value; Sum() : value(0) {} Sum( Sum& s, split ) {value = 0;} void operator()( const blocked_range<float*>& range ) { float temp = value; for( float* a=range.begin(); a!=range.end(); ++a ) { temp += *a; } value = temp; } void join( Sum& rhs ) {value += rhs.value;} }; float ParallelSum( float array[], size_t n ) { Sum total; parallel_reduce( blocked_range<float*>( array, array+n, 1000 ), total ); return total.value; } op 0 op += op= Sum op op Partitioner Partitioner template<typename Range, typename Body, typename Partitioner> void parallel_reduce( const Range& range, Body& body, Partitioner &partitioner ); #include "tbb/parallel_reduce.h" 32

43 parallel_reduce<range,body> Range Body Range Range (3.2) Body 9 Partitioner Partitioner (3.3) auto_partitioner #include "tbb/parallel_reduce.h" #include "tbb/blocked_range.h" using namespace tbb; struct Sum { float value; Sum() : value(0) {} Sum( Sum& s, split ) {value = 0;} void operator()( const blocked_range<float*>& range ) { float temp = value; for( float* a=range.begin(); a!=range.end(); ++a ) { temp += *a; } value = temp; } void join( Sum& rhs ) {value += rhs.value;} }; float ParallelSum( float array[], size_t n ) { Sum total; parallel_reduce( blocked_range<float*>( array, array+n ), total, auto_partitioner() ); return total.value; } 2 (1) parallel_reduce 3 auto_partitioner (2) blocked_range blocked_range 1 8 simple_partitioner auto_partitioner 33

44 3.6 parallel_scan<range,body> template<typename Range, typename Body> void parallel_scan( const Range& range, Body& body ); #include "tbb/parallel_scan.h" parallel_scan<range,body> () id x0, x1,...xn-1 y0, y1, y2,...yn-1 y0 = id x0 yi = yi 1 xi T temp = id ; for( int i=1; i<=n; ++i ) { temp = temp x[i]; y[i] = temp; }

45 : parallel_scan 2 2 parallel_scan 1 parallel_scan<range,body> 10 10: parallel_scan void Body::operator()( const Range& r, pre_scan_tag ) void Body::operator()( const Range& r, final_scan_tag ) r r Body::Body( Body& b, split ) void Body::reverse_join( Body& a ) this b b a this a b b void Body::assign( Body& b ) b this parallel_scan using namespace tbb; class Body { T sum; T* const y; const T* const x; public: Body( T y_[], const T x_[] ) : sum(0), x(x_), y(y_) {} T get_sum() const {return sum;} template<typename Tag> void operator()( const blocked_range<int>& r, Tag ) { T temp = sum; for( int i=r.begin(); i<r.end(); ++i ) { temp = temp x[i]; if( Tag::is_final_scan() ) y[i] = temp; } 35

46 }; sum = temp; } Body( Body& b, split ) : x(b.x), y(b.y), sum(id ) {} void reverse_join( Body& a ) { sum = a.sum sum;} void assign( Body& b ) {sum = b.sum;} float DoParallelScan( T y[], const T x[], int n) { Body body(y,x); parallel_scan( blocked_range<int>(0,n,1000), body ); return body.get_sum(); } operator() parallel_scan 1 2 is_final_scan() y parallel_scan y reverse_join parallel_reduce join this parallel_scan Body parallel_scan pre_scan_tag and final_scan_tag parallel_scan struct pre_scan_tag; struct final_scan_tag; 36

47 #include "tbb/parallel_scan.h" pre_scan_tag final_scan_tag parallel_scan operator() 3.6 namespace tbb { } struct pre_scan_tag { static bool is_final_scan(); }; struct final_scan_tag { static bool is_final_scan(); }; bool is_final_scan() final_scan_tag true false Partitioner Partitioner template<typename Range, typename Body, typename Partitioner> void parallel_scan( const Range& range, Body& body, Partitioner &partitioner ); 37

48 #include "tbb/parallel_scan.h" parallel_scan<range,body,partitioner> ( ) ( 3.6 ) auto_partitioner using namespace tbb; class Body { T sum; T* const y; const T* const x; public: Body( T y_[], const T x_[] ) : sum(0), x(x_), y(y_) {} T get_sum() const {return sum;} }; template<typename Tag> void operator()( const blocked_range<int>& r, Tag ) { T temp = sum; for( int i=r.begin(); i<r.end(); ++i ) { temp = temp x[i]; if( Tag::is_final_scan() ) y[i] = temp; } sum = temp; } Body( Body& b, split ) : x(b.x), y(b.y), sum(id ) {} void reverse_join( Body& a ) { sum = a.sum sum;} void assign( Body& b ) {sum = b.sum;} float DoParallelScan( T y[], const T x[], int n) { Body body(y,x); parallel_scan( blocked_range<int>(0,n), body, auto_partitioner() ); return body.get_sum(); } 2 (1) parallel_scan 3 auto_partitioner (2) blocked_range blocked_range 1 38

49 8 simple_partitioner auto_partitioner 3.7 parallel_while template<typename Body> class parallel_while; #include "tbb/parallel_while.h" parallel_while<body> Body : S B parallel_while bool S::pop_if_present( B::argument_type& item ) B::operator()( B::argument_type& item ) const B::argument_type() parallel_while this item parallel_while this item operator 39

50 B::argument_type( const B::argument_type& ) ~B::argument_type() C B concurrent_queue (4.2) S : B::operator() 10,000 parallel_while parallel_while add 2 namespace tbb { template<typename Body> class parallel_while { public: parallel_while(); ~parallel_while(); typedef typename Body::argument_type value_type; template<typename Stream> void run( Stream& stream, const Body& body ); } }; void add( const value_type& item ); parallel_while<body>() parallel_while ~parallel_while<body>() parallel_while 40

51 3.7.3 <typename Stream> void run( Stream& stream, const Body& body ) body stream add 1. stream.pop_if_present false 2. body(x) add x void add( const value_type& item ) parallel_while body.operator() run 3.8 pipeline class pipeline; #include "tbb/pipeline.h" 41

52 pipeline filter (3.8.6) fi 1 i f0 f1 f filter fi fi filter ( ) 2. filter filter::operator() f0 NULL 3. pipeline 4. fi 2 5. pipeline::run max_number_of_live_tokens max_number_of_live_tokens pipeline filter pipeline pipeline pipeline::clear() namespace tbb { class pipeline { public: pipeline(); virtual ~pipeline(); 42

53 } }; void add_filter( filter& f ); void run( size_t max_number_of_live_tokens ); void clear(); pipeline() ~pipeline() void add_filter( filter& f ) f f void run( size_t max_number_of_live_tokens ) NULL max_number_of_live_tokens 43

54 3.8.5 void clear() filter class filter; #include "tbb/pipeline.h" filter pipeline (3.8) 1 filter pipeline (3.8) namespace tbb { class filter { protected: filter( bool is_serial ); public: bool is_serial() const; virtual void* operator()( void* item ) = 0; virtual ~filter(); }; } 44

55 (doc/tutorial.pdf) MyInputFilter MyTransformFilter MyOutputFilter filter( bool is_serial ) is_serial true is_serial false ~filter() pipeline pipeline pipeline pipeline C bool is_serial() const true false virtual void* operator()( void * item ) filter NULL 45

56 pipeline NULL pipeline 3.9 parallel_sort<randomaccessiterator, Compare> template<typename RandomAccessIterator> void parallel_sort(randomaccessiterator begin, RandomAccessIterator end); template<typename RandomAccessIterator, typename Compare> void parallel_sort(randomaccessiterator begin, RandomAccessIterator end, const Compare& comp ); #include "tbb/parallel_sort.h" [begin1, end1) unstable unstable std::sort RandomAccessIterator T 12 12: RandomAccessIterator T void swap( T& x, T& y ) bool Compare::operator()( const T& x, const T& y ) x y x y true false 46

57 parallel_sort(i,j,comp) 2 comp [i,j) comp(x,y) true x y parallel_sort(i,j) parallel_sort(i,j,std::less<t>) parallel_sort O(N log (N)) N (8.2.1) parallel_sort 2 a b std::greater<float> #include "tbb/parallel_sort.h" #include <math.h> using namespace tbb; const int N = ; float a[n]; float b[n]; void SortExample() { for( int i = 0; i < N; i++ ) { a[i] = sin((double)i); b[i] = cos((double)i); } parallel_sort(a, a + N); parallel_sort(b, b + N, std::greater<float>()); } 47

58 4 STL allocator 4.1 concurrent_hash_map<key,t, HashCompare> template<typename Key, typename T, typename HashCompare> class concurrent_hash_map; #include "tbb/concurrent_hash_map.h" concurrent_hash_map STL Key T CopyConstructible (2.2.3) HashCompare 13 HashCompare 48

59 13: HashCompare HashCompare::HashCompare( const HashCompare & ) HashCompare::~HashCompare () bool HashCompare::equal( const Key& j, const Key& k ) const size_t HashCompare::hash( const Key& k ) true : 2 HashCompare h 2 j k "!h.equal(j,k) h.hash(j)==h.hash(k)" concurrent_hash_map namespace tbb { template<typename Key, typename T, typename HashCompare> class concurrent_hash_map { public: // types typedef Key key_type; typedef T mapped_type; typedef std::pair<const Key,T> value_type; typedef size_t size_type; typedef ptrdiff_t difference_type; // whole-table operations concurrent_hash_map(); concurrent_hash_map( const concurrent_hash_map& ); ~concurrent_hash_map(); concurrent_hash_map operator=( const concurrent_hash_map& ); void clear(); // concurrent access class const_accessor; class accessor; // concurrent operations on a table bool find( const_accessor& result, const Key& key ) const; bool find( accessor& result, const Key& key ); bool insert( const_accessor& result, const Key& key ); bool insert( accessor& result, const Key& key ); bool erase( const Key& key ); // parallel iteration 49

60 } }; typedef implementation defined range_type; typedef implementation defined const_range_type; range_type range( size_t grainsize ); const_range_type range( size_t grainsize ) const; // Capacity size_type size() const; bool empty() const; size_type max_size() const; // Iterators typedef implementation defined iterator; typedef implementation defined const_iterator; iterator begin(); iterator end(); const_iterator begin() const; const_iterator end() const; concurrent_hash_map() concurrent_hash_map( const concurrent_hash_map& table ) ~concurrent_hash_map() concurrent_hash_map 50

61 concurrent_hash_map& operator= ( concurrent_hash_map& source ) (this) / void clear() / const_accessor accessor concurrent_hash_map concurrent_hash_map release const_accessor accessor 51

62 14: const_accessor accessor value_type pair const_accessor const std::pair<const Key,T> accessor std::pair<const Key,T> const_accessor concurrent_hash_map / template<typename Key, typename T, typename HashCompare> class concurrent_hash_map<key,t,hashcompare>::const_accessor; #include "tbb/concurrent_hash_map.h" const_accessor concurrent_hash_map / namespace tbb { template<typename Key, typename T, typename HashCompare> class concurrent_hash_map<key,t,hashcompare>::const_accessor { public: // types typedef const std::pair<const Key,T> value_type; // construction and destruction const_accessor(); 52

63 } }; ~const_accessor(); // inspection bool empty() const; const value_type& operator*() const; const value_type* operator->() const; // early release void release(); bool empty() const ture/ false void release()!empty() const value_type& operator*() const empty() TBB_DO_ASSERT (2.6.1) / const const value_type* operator->() const &operator*() 53

64 const_accessor() const_accessor ~const_accessor / accessor concurrent_hash_map / template<typename Key, typename T, typename HashCompare> class concurrent_hash_map<key,t,hashcompare>::accessor; #include "tbb/concurrent_hash_map.h" accessor concurrent_hash_map / / const_accessor const_accessor namespace tbb { template<typename Key, typename T, typename HashCompare> class concurrent_hash_map<key,t,hashcompare>::accessor: concurrent_hash_map<key,t,hashcompare>::const_accessor { public: typedef std::pair<const Key,T> value_type; value_type& operator*() const; value_type* operator->() const; }; } 54

65 value_type& operator*() const empty() TBB_DO_ASSERT (2.6.1) / value_type* operator->() const &operator*() find insert erase concurrent_hash_map / find insert 2 1 const_accessor / 1 accessor : nonconst const true bool find( const_accessor& result, const Key& key ) const 55

66 ture false bool find( accessor& result, const Key& key ) ture false bool insert( const_accessor& result, const Key& key ) pair(key,t()) true false bool insert( accessor& result, const Key& key ) pair(key,t()) true false 56

67 bool erase(const Key& key ) true false const_range_type range_type Range (3.2) 15 const_range_type const_iterator range_type iterator concurrent_hash_map parallel_for (3.4) parallel_reduce (3.5) parallel_scan (3.6) 15: concurrent_hash_map Range R ( 4 ) R::iterator R::begin() const R::iterator R::end() const const_range_type range( size_t grainsize ) const const_range_type grainsize 1 / const_range_type 57

68 range_type range( size_t grainsize ) range_type size_type size() const / : STL bool empty() const size()==0 : STL size_type max_size() const / concurrent_hash_map ( ) iterator begin() / iterator 58

69 iterator end() / iterator const_iterator begin() const / const_iterator const_iterator end() const / const_iterator 4.2 concurrent_queue<t> template<typename T> class concurrent_queue; #include "tbb/concurrent_queue.h" concurrent_queue FIFO () 59

70 concurrent_queue STL std::queue 16: STL concurrent_queue STL std::queue concurrent_queue front back front back size_type size() size() q q x=q.front(); q.pop() bool b=!q.empty(); if(b) { x=q.front(); q.pop(); } q.pop(x) bool b = q.pop_if_present(x) : concurrent_queue namespace tbb { template<typename T> class concurrent_queue { public: // types typedef T value_type; typedef T& reference; typedef const T& const_reference; typedef std::ptrdiff_t size_type; typedef std::ptrdiff_t difference_type; 60

71 } }; concurrent_queue() {} ~concurrent_queue(); void push( const T& source ); void pop( T& destination ); bool pop_if_present( T& destination ); size_type size() const {return internal_size();} bool empty() const; size_t capacity() const; void set_capacity( size_type capacity ); typedef implementation-defined iterator; typedef implementation-defined const_iterator; // iterators (these are slow an intended only for debugging) iterator begin(); iterator end(); const_iterator begin() const; const_iterator end() const; concurrent_queue() ~concurrent_queue() void push( const T& source ) size()<capacity source 61

72 4.2.4 void pop( T& destination ) destination bool pop_if_present( T& destination ) destination true false size_type size() const bool empty() const size()== size_type capacity() const 62

73 4.2.9 void set_capacity( size_type capacity ) concurrent_queue iterator const_iterator STL concurrent_queue : #include "tbb/concurrent_queue.h" #include <iostream> using namespace std; using namespace tbb; int main() { concurrent_queue<int> queue; for( int i=0; i<10; ++i ) queue.push(i); for( concurrent_queue<int>::const_iterator i(queue.begin()); i!=queue.end(); ++i ) cout << *i << " "; cout << endl; return 0; } iterator begin() iterator 63

74 iterator end() iterator const_iterator begin() const const_iterator const_iterator end() const const_iterator 4.3 concurrent_vector template<typename T> class concurrent_vector; #include "tbb/concurrent_vector.h" concurrent_vector 0 namespace tbb { template<typename T> class concurrent_vector { 64

75 public: typedef size_t size_type; typedef T value_type; typedef ptrdiff_t difference_type; typedef T& reference; typedef const T& const_reference; // whole vector operations concurrent_vector() {} concurrent_vector( const concurrent_vector& ); concurrent_vector& operator=( const concurrent_vector&); ~concurrent_vector(); void clear(); // concurrent operations size_type grow_by( size_type delta ); void grow_to_at_least( size_type new_size ); size_type push_back( const_reference value ); reference operator[]( size_type index ); const_reference operator[]( size_type index ) const; // parallel iteration typedef implementation-defined iterator; typedef implementation-defined const_iterator; typedef generic_range_type<iterator> range_type; typedef generic_range_type<const_iterator> const_range_type; range_type range( size_t grainsize ); const_range_type range( size_t grainsize ) const; // capacity size_type size() const; bool empty() const; size_type capacity() const; void reserve( size_type n ); size_type max_size() const; // STL support iterator begin(); iterator end(); const_iterator begin() const; const_iterator end() const; } }; typedef implementation-defined reverse_iterator; typedef implementation-defined const_reverse_iterator; iterator rbegin(); iterator rend(); const_iterator rbegin() const; const_iterator rend() const; 65

76 concurrent_vector() concurrent_vector( const concurrent_vector& src ) src concurrent_vector& operator=( const concurrent_vector& src ) src *this ~concurrent_vector() void clear() size()==0 66

77 4.3.2 concurrent_vector<t> size_type grow_by( size_type delta ) delta T() T value_type k (k..k+delta) void grow_to_at_least( size_type n ) n T() T value_type size_t push_back( const_reference value ); value reference operator[]( size_type index ) 67

78 const_reference operator[]( size_type index ) const; const const_range_type range_type Range (3.2) 15 const_range_type const_iterator range_type iterator concurrent_vector parallel_for (3.4) parallel_reduce (3.5) parallel_scan (3.6) 17: concurrent_vector Range R R::iterator R::begin() const R::iterator R::end() const range_type range( size_t grainsize ) / concurrent_vector const_range_type range( size_t grainsize ) const concurrent_vector 68

79 size_type size() const grow_by ( ) grow_to_at_least ( ) bool empty() const size()== size_type capacity() const : STL concurrent_vector void reserve( size_type n ) n n>max_size() std::length_error size_type max_size() const 69

80 4.3.5 concurrent_vector<t> ISO C std::vector concurrent_vector<t> ISO C iterator begin() iterator iterator end() iterator const_iterator begin() const const_iterator const_iterator end() const const_iterator iterator rbegin() const_reverse_iterator(end()) iterator rend() const_reverse_iterator(begin()) 70

81 const_reverse_iterator rbegin() const const_reverse_iterator(end()) const_ reverse_iterator rend() const const_reverse_iterator(begin()) 71

82 5 5.1 Allocator Allocator ISO C++ 32 "Allocator " ISO C++ ISO C++ ( ) 18 Allocator A B 18: Allocator typedef T* A::pointer typedef const T* A::const_pointer typedef T& A::reference typedef const T& A::const_reference typedef T A::value_type typedef size_t A::size_type typedef ptrdiff_t A::difference_type template<typename U> struct rebind { typedef A<U> A::other; }; A() throw() T const T T const T U A( const A& ) throw() template<typename U> A( const A& ) ~A() throw() T* A::address( T& x ) const const T* A::const_address( const T& x ) const 72

83 const T* A::allocate( size_type n, void* hint=0 ) n void A::deallocate( T* p, size_t n ) size_type A::max_size() const throw() n allocate void A::construct( T* p, const T& value ) void A::destroy( T* p ) bool operator==( const A&, const B& ) bool operator!=( const A&, const B& ) new(p) T(value) p->t::~t() true false scalable_allocator (5.2) cached_aligned_allocator (5.3) Allocator 5.2 scalable_allocator<t> template<typename T> class scalable_allocator; #include "tbb/scalable_allocator.h" scalable_allocator scalable_allocator 18 allocator std::allocator scalable_allocator 73

84 scalable_allocator std::allocator scalable_allocator Allocator (5.1) PSL CTG McRT C extern "C" { void* scalable_calloc ( size_t nobj, size_t size ); void scalable_free( void* ptr ); void* scalable_malloc( size_t size ); void* scalable_realloc( void* ptr, size_t size ); } #include "tbb/scalable_allocator.h" C scalable_x C x scalable_x C scalable_x C scalable_x 74

85 5.3 cache_aligned_allocator<t> template<typename T> class cache_aligned_allocator; #include "tbb/cache_aligned_allocator.h" cache_aligned_allocator cache_aligned_allocator 18 allocator std::allocator cache_aligned_allocator cache_aligned_allocator 128 cache_aligned_allocator 75

86 namespace tbb { template<typename T> class NFS_Allocator { public: typedef T* pointer; typedef const T* const_pointer; typedef T& reference; typedef const T& const_reference; typedef T value_type; typedef size_t size_type; typedef ptrdiff_t difference_type; template<typename U> struct rebind { typedef cache_aligned_allocator<u> other; }; #if _WIN64 char* _Charalloc( size_type size ); #endif /* _WIN64 */ cache_aligned_allocator() throw(); cache_aligned_allocator( const cache_aligned_allocator& ) throw(); template<typename U> cache_aligned_allocator( const cache_aligned_allocator<u>& ) throw(); ~cache_aligned_allocator(); pointer address(reference x) const; const_pointer address(const_reference x) const; pointer allocate( size_type n, void* hint=0 ); void deallocate( pointer p, size_type ); size_type max_size() const throw(); }; void construct( pointer p, const T& value ); void destroy( pointer p ); template<> class cache_aligned_allocator<void> { public: typedef void* pointer; typedef const void* const_pointer; typedef void value_type; template<typename U> struct rebind { typedef cache_aligned_allocator<u> other; }; }; template<typename T, typename U> bool operator==( const cache_aligned_allocator<t>&, 76

87 const cache_aligned_allocator<u>& ); template<typename T, typename U> bool operator!=( const cache_aligned_allocator<t>&, const cache_aligned_allocator<u>& ); } std::allocator pointer allocate( size_type n, void* hint=0 ) size void deallocate( pointer p, size_type n ) p allocate(n) p char* _Charalloc( size_type size ) : 64 Windows* Windows ISO 77

88 5.4 aligned_space template<typename T, size_t N> class aligned_space; #include "tbb/aligned_space.h" aligned_space T[N] aligned_space namespace tbb { template<typename T, size_t N> class aligned_space { public: aligned_space(); ~aligned_space(); T* begin(); T* end(); }; } aligned_space() 78

89 5.4.2 ~aligned_space() T* begin() T* end() begin()+n 79

90 6 6.1 Mutex Mutex (MUTual EXclusion) mutex Mutex mutex C (mutex ) mutex lock lock 2 { } // Construction of mylock acquires lock on mymutex M::scoped_lock mylock( mymutex );... actions to be performed while holding the lock... // Destruction of mylock releases lock on mymutex 19 mutex M Mutex 80

91 19: Mutex M() ~M() typename M::scoped_lock M::scoped_lock() M::scoped_lock(M&) M::~scoped_lock() M::scoped_lock::acquire(M&) bool M::scoped_lock::try_acquire(M&) mutex mutex mutex mutex () mutex mutex true false M::scoped_lock::release() 20 Mutex 20: Mutex mutex mutex OS OS 3 spin_mutex 1 queuing_mutex 1 spin_rw_mutex 1 queuing_rw_mutex 1 mutex mutex OS Mutex 81

92 class mutex; #include "tbb/mutex.h" mutex Mutex (46.1.1) mutex OS OS mutex Mutex (6.1.1) spin_mutex Mutex class spin_mutex; #include "tbb/spin_mutex.h" spin_mutex Mutex (6.1.1) spin_mutex spin_mutex 82

93 spin_mutex mutex Mutex (6.1.1) queuing_mutex Mutex class queuing_mutex; #include "tbb/queuing_mutex.h" queuing_mutex Mutex (6.1.1) mutex queuing_mutex queuing_mutex queuing_mutex queuing_mutex queuing_mutex Mutex (6.1.1) ReaderWriterMutex ReaderWriterMutex Mutex (write =true) 83

94 (write =false) write ReaderWriterMutex ReaderWriterMutex mutex 21 ReaderWriterMutex RW 21: ReaderWriterMutex RW() ~RW() typename RW::scoped_lock RW::scoped_lock() RW::scoped_lock(RW&, bool write=true) mutex mutex mutex mutex RW::~scoped_lock() ( ) RW::scoped_lock::acquire(RW&, bool write=true) bool RW::scoped_lock::try_acquire(RW&, bool write=true) mutex mutex true false RW::scoped_lock::release() bool RW::scoped_lock::upgrade_to_writer() bool RW::scoped_lock::downgrade_to_reader() ReaderWriterMutex spin_rw_mutex (6.1.6) queuing_rw_mutex (6.1.7) ReaderWriterMutex 84

95 ReaderWriterMutex() ReaderWriterMutex ~ReaderWriterMutex() ReaderWriterMutex ReaderWriterMutex ReaderWriterMutex::scoped_lock() mutex scoped_lock ReaderWriterMutex::scoped_lock( ReaderWriterMutex& rw, bool write =true) mutex rw scoped_lock write true ReaderWriterMutex::~scoped_lock() ReaderWriterMutex void ReaderWriterMutex:: scoped_lock:: acquire( ReaderWriterMutex& rw, bool write=true ) mutex rw write true 85

96 bool ReaderWriterMutex:: scoped_lock::try_acquire( ReaderWriterMutex& rw, bool write=true ) mutex rw write true true false void ReaderWriterMutex:: scoped_lock::release() bool ReaderWriterMutex:: scoped_lock::upgrade_to_writer() false true bool ReaderWriterMutex:: scoped_lock::downgrade_to_reader() false true 86

97 : spin_rw_mutex queuing_rw_mutex true false spin_rw_mutex ReaderWriterMutex class spin_rw_mutex; #include "tbb/spin_rw_mutex.h" spin_rw_mutex ReaderWriterMutex (6.1.1) spin_rw_mutex spin_rw_mutex spin_rw_mutex mutex ReaderWriterMutex (6.1.5) queuing_rw_mutex ReaderWriterMutex class queuing_rw_mutex; 87

98 #include "tbb/queuing_rw_mutex.h" queuing_rw_mutex ReaderWriterMutex (6.1.1) mutex queuing_rw_mutex queuing_rw_mutex queuing_rw_mutex queuing_rw_mutex ReaderWriterMutex (6.1.5) 6.2 atomic<t> template<typename T> atomic; #include "tbb/atomic.h" atomic<t> read write fetch-and-add fetch-and-store compare-andswap T T x atomic<float*> float 4 ++x 4 x atomic<void*> IA

99 Itanium 22 22: acquire read release write full fetch_and_store, fetch_and_add, compare_and_swap : atomic<t> atomic<t> atomic<t> namespace tbb { enum memory_semantics { acquire, release }; struct atomic<t> { typedef T value_type; template<memory_semantics M> value_type fetch_and_add( value_type addend ); value_type fetch_and_add( value_type addend ); template<memory_semantics M> value_type fetch_and_increment(); value_type fetch_and_increment(); template<memory_semantics M> value_type fetch_and_decrement(); value_type fetch_and_decrement(); template<memory_semantics M> value_type compare_and_swap( value_type new_value, value_type comparand ); 89

インテル® ソフトウェア開発製品

インテル® ソフトウェア開発製品 インテル ソフトウェア開発製品 James Reinders セールス & マーケティング ディレクター インテル ソフトウェア開発製品 XML インテル C++ コンパイラーは Windows* Linux* Mac OS* X で開発を行う Microsoft* と gcc (GNU) ユーザーの最も一般的なアップグレード パス インテル Fortran コンパイラーは 現在最も使われている Fortran

More information

(STL) STL 1 (deta structure) (algorithm) (deta structure) 2 STL STL (Standard Template Library) 2.1 STL STL ( ) vector<int> x; for(int i = 0; i < 10;

(STL) STL 1 (deta structure) (algorithm) (deta structure) 2 STL STL (Standard Template Library) 2.1 STL STL ( ) vector<int> x; for(int i = 0; i < 10; (STL) STL 1 (deta structure) (algorithm) (deta structure) 2 STL STL (Standard Template Library) 2.1 STL STL ( ) vector x; for(int i = 0; i < 10; ++i) x.push_back(i); vector STL x.push_back(i) STL

More information

cpp1.dvi

cpp1.dvi 2017 c 1 C++ (1) C C++, C++, C 11, 12 13 (1) 14 (2) 11 1 n C++ //, [List 11] 1: #include // C 2: 3: int main(void) { 4: std::cout

More information

解きながら学ぶC++入門編

解きながら学ぶC++入門編 !... 38!=... 35 "... 112 " "... 311 " "... 4, 264 #... 371 #define... 126, 371 #endif... 369 #if... 369 #ifndef... 369 #include... 3, 311 #undef... 371 %... 17, 18 %=... 85 &... 222 &... 203 &&... 40 &=...

More information

cpp2.dvi

cpp2.dvi 2018 c 2 C++ (2) STL, C++ 21 string 22 STL 23 21 string C, \0, (, ), (, ), /,,,, C++,,, string string,,,,,, include,,, int, > >>,,,, getline(, string ), [List 21] 2: #include 3: 4:

More information

新版明解C言語 実践編

新版明解C言語 実践編 2 List - "max.h" a, b max List - max "max.h" #define max(a, b) ((a) > (b)? (a) : (b)) max List -2 List -2 max #include "max.h" int x, y; printf("x"); printf("y"); scanf("%d", &x); scanf("%d", &y); printf("max(x,

More information

1.3 ( ) ( ) C

1.3 ( ) ( ) C 1 1.1 (Data Base) (Container) C++ Java 1.2 1 1.3 ( ) ( ) 1. 2. 3. C++ 2 2.1 2.2 2.3 2 C Fortran C++ Java 3 3.1 (Vector) 1. 2. ( ) 3.2 3 3.3 C++ C++ STL C++ (Template) vector vector< > ; int arrayint vector

More information

ohp03.dvi

ohp03.dvi 19 3 ( ) 2019.4.20 CS 1 (comand line arguments) Unix./a.out aa bbb ccc ( ) C main void int main(int argc, char *argv[]) {... 2 (2) argc argv argc ( ) argv (C char ) ( 1) argc 4 argv NULL. / a. o u t \0

More information

Condition DAQ condition condition 2 3 XML key value

Condition DAQ condition condition 2 3 XML key value Condition DAQ condition 2009 6 10 2009 7 2 2009 7 3 2010 8 3 1 2 2 condition 2 3 XML key value 3 4 4 4.1............................. 5 4.2...................... 5 5 6 6 Makefile 7 7 9 7.1 Condition.h.............................

More information

北米アジャイル界デビュー fkinoからは 何も聞いてませんでした これまでに書いたもの Web 2.0 ビギナーズバイブル エンジニアマインド vol.5 開発の現場 vol.011 Dave 達人 Thomasも云ってたよ http://jp.rubyist.net/rubykaigi2007/?c=plugin;plugin=attach_download;p=program0610;file_name=the_island_of_ruby_j.pdf

More information

3.1 stdio.h iostream List.2 using namespace std C printf ( ) %d %f %s %d C++ cout cout List.2 Hello World! cout << float a = 1.2f; int b = 3; cout <<

3.1 stdio.h iostream List.2 using namespace std C printf ( ) %d %f %s %d C++ cout cout List.2 Hello World! cout << float a = 1.2f; int b = 3; cout << C++ C C++ 1 C++ C++ C C++ C C++? C C++ C *.c *.cpp C cpp VC C++ 2 C++ C++ C++ [1], C++,,1999 [2],,,2001 [3], ( )( ),,2001 [4] B.W. /D.M.,, C,,1989 C Web [5], http://kumei.ne.jp/c_lang/ 3 Hello World Hello

More information

r03.dvi

r03.dvi 19 ( ) 019.4.0 CS 1 (comand line arguments) Unix./a.out aa bbb ccc ( ) C main void... argc argv argc ( ) argv (C char ) ( 1) argc 4 argv NULL. / a. o u t \0 a a \0 b b b \0 c c c \0 1: // argdemo1.c ---

More information

連載講座 : 高生産並列言語を使いこなす (5) 分子動力学シミュレーション 田浦健次朗 東京大学大学院情報理工学系研究科, 情報基盤センター 目次 1 問題の定義 17 2 逐次プログラム 分子 ( 粒子 ) セル 系の状態 ステップ 18

連載講座 : 高生産並列言語を使いこなす (5) 分子動力学シミュレーション 田浦健次朗 東京大学大学院情報理工学系研究科, 情報基盤センター 目次 1 問題の定義 17 2 逐次プログラム 分子 ( 粒子 ) セル 系の状態 ステップ 18 連載講座 : 高生産並列言語を使いこなす (5) 分子動力学シミュレーション 田浦健次朗 東京大学大学院情報理工学系研究科, 情報基盤センター 目次 1 問題の定義 17 2 逐次プログラム 17 2.1 分子 ( 粒子 ) 17 2.2 セル 17 2.3 系の状態 18 2.4 1ステップ 18 2.5 力の計算 19 2.6 速度と位置の更新 20 2.7 セル間の分子の移動 21 3 OpenMP

More information

- - http://168iroha.net 018 10 14 i 1 1 1.1.................................................... 1 1.................................................... 7.1................................................

More information

困ったときのQ&A

困ったときのQ&A ii iii iv NEC Corporation 1997 v P A R T 1 vi vii P A R T 2 viii P A R T 3 ix x xi 1P A R T 2 1 3 4 1 5 6 1 7 8 1 9 1 2 3 4 10 1 11 12 1 13 14 1 1 2 15 16 1 2 1 1 2 3 4 5 17 18 1 2 3 1 19 20 1 21 22 1

More information

1 C STL(1) C C C libc C C C++ STL(Standard Template Library ) libc libc C++ C STL libc STL iostream Algorithm libc STL string vector l

1 C STL(1) C C C libc C C C++ STL(Standard Template Library ) libc libc C++ C STL libc STL iostream Algorithm libc STL string vector l C/C++ 2007 6 18 1 C STL(1) 2 1.1............................................... 2 1.2 stdio................................................ 3 1.3.......................................... 10 2 11 2.1 sizeof......................................

More information

( ) ( ) 30 ( ) 27 [1] p LIFO(last in first out, ) (push) (pup) 1

( ) ( ) 30 ( ) 27 [1] p LIFO(last in first out, ) (push) (pup) 1 () 2006 2 27 1 10 23 () 30 () 27 [1] p.97252 7 2 2.1 2.1.1 1 LIFO(last in first out, ) (push) (pup) 1 1: 2.1.2 1 List 4-1(p.100) stack[] stack top 1 2 (push) (pop) 1 2 void stack push(double val) val stack

More information

活用ガイド (ソフトウェア編)

活用ガイド (ソフトウェア編) (Windows 95 ) ii iii iv NEC Corporation 1999 v P A R T 1 vi P A R T 2 vii P A R T 3 P A R T 4 viii P A R T 5 ix x P A R T 1 2 3 1 1 2 4 1 2 3 4 5 1 1 2 3 4 6 5 6 7 7 1 1 2 8 1 9 1 1 2 3 4 5 6 1 2 3 4

More information

IntelR Compilers Professional Editions

IntelR Compilers Professional Editions June 2007 インテル コンパイラー プロフェッショナル エディション Phil De La Zerda 公開が禁止された情報が含まれています 本資料に含まれるインテル コンパイラー 10.0 についての情報は 6 月 5 日まで公開が禁止されています グローバル ビジネス デベロップメント ディレクター Intel Corporation マルチコア プロセッサーがもたらす変革 これまでは

More information

r07.dvi

r07.dvi 19 7 ( ) 2019.4.20 1 1.1 (data structure ( (dynamic data structure 1 malloc C free C (garbage collection GC C GC(conservative GC 2 1.2 data next p 3 5 7 9 p 3 5 7 9 p 3 5 7 9 1 1: (single linked list 1

More information

活用ガイド (ハードウェア編)

活用ガイド (ハードウェア編) (Windows 98) 808-877675-122-A ii iii iv NEC Corporation 1999 v vi PART 1 vii viii PART 2 PART 3 ix x xi xii P A R T 1 2 1 3 4 1 5 6 1 7 8 1 9 10 11 1 12 1 1 2 3 13 1 2 3 14 4 5 1 15 1 1 16 1 17 18 1 19

More information

ohp07.dvi

ohp07.dvi 19 7 ( ) 2019.4.20 1 (data structure) ( ) (dynamic data structure) 1 malloc C free 1 (static data structure) 2 (2) C (garbage collection GC) C GC(conservative GC) 2 2 conservative GC 3 data next p 3 5

More information

活用ガイド (ソフトウェア編)

活用ガイド (ソフトウェア編) (Windows 98 ) ii iii iv v NEC Corporation 1999 vi P A R T 1 P A R T 2 vii P A R T 3 viii P A R T 4 ix P A R T 5 x P A R T 1 2 3 1 1 2 4 1 2 3 4 5 1 1 2 3 4 5 6 6 7 7 1 1 2 8 1 9 1 1 2 3 4 5 6 1 2 3 10

More information

LIFO(last in first out, ) 1 FIFO(first in first out, ) 2 2 PUSH POP : 1

LIFO(last in first out, ) 1 FIFO(first in first out, ) 2 2 PUSH POP : 1 2007 7 17 2 1 1.1 LIFO(last in first out, ) 1 FIFO(first in first out, ) 2 2 PUSH POP 2 2 5 5 5 1: 1 2 データの追加 データの取り出し 5 2 5 2 5 2: 1.2 [1] pp.199 217 2 (binary tree) 2 2.1 (three: ) ( ) 秋田高専 校長 準学士課程学生

More information

エクセルカバー入稿用.indd

エクセルカバー入稿用.indd i 1 1 2 3 5 5 6 7 7 8 9 9 10 11 11 11 12 2 13 13 14 15 15 16 17 17 ii CONTENTS 18 18 21 22 22 24 25 26 27 27 28 29 30 31 32 36 37 40 40 42 43 44 44 46 47 48 iii 48 50 51 52 54 55 59 61 62 64 65 66 67 68

More information

6-1

6-1 6-1 (data type) 6-2 6-3 ML, Haskell, Scala Lisp, Prolog (setq x 123) (+ x 456) (setq x "abc") (+ x 456) ; 6-4 ( ) subtype INDEX is INTEGER range -10..10; type DAY is (MON, TUE, WED, THU, FRI, SAT, SUN);

More information

01_.g.r..

01_.g.r.. I II III IV V VI VII VIII IX X XI I II III IV V I I I II II II I I YS-1 I YS-2 I YS-3 I YS-4 I YS-5 I YS-6 I YS-7 II II YS-1 II YS-2 II YS-3 II YS-4 II YS-5 II YS-6 II YS-7 III III YS-1 III YS-2

More information

DPD Software Development Products Overview

DPD Software Development Products Overview 2 2007 Intel Corporation. Core 2 Core 2 Duo 2006/07/27 Core 2 precise VTune Core 2 Quad 2006/11/14 VTune Core 2 ( ) 1 David Levinthal 3 2007 Intel Corporation. PC Core 2 Extreme QX6800 2.93GHz, 1066MHz

More information

untitled

untitled Fortran90 ( ) 17 12 29 1 Fortran90 Fortran90 FORTRAN77 Fortran90 1 Fortran90 module 1.1 Windows Windows UNIX Cygwin (http://www.cygwin.com) C\: Install Cygwin f77 emacs latex ps2eps dvips Fortran90 Intel

More information

untitled

untitled C -1 - -2 - concept lecture keywords FILE, fopen, fclose, fscanf, fprintf, EOF, r w a, typedef gifts.dat Yt JZK-3 Jizake tsumeawase 45 BSP-15 Body soap set 3 BT-2 Bath towel set 25 TEA-2 Koutya

More information

design_pattern.key

design_pattern.key #include void init(int* ary, int size) for (int i = 0; i < size; ++i) ary[i] = i; void mul10(int* ary, int size) for (int i = 0; i < size; ++i) ary[i] *= 10; void dispary(int* ary, int size)

More information

SC-85X2取説

SC-85X2取説 I II III IV V VI .................. VII VIII IX X 1-1 1-2 1-3 1-4 ( ) 1-5 1-6 2-1 2-2 3-1 3-2 3-3 8 3-4 3-5 3-6 3-7 ) ) - - 3-8 3-9 4-1 4-2 4-3 4-4 4-5 4-6 5-1 5-2 5-3 5-4 5-5 5-6 5-7 5-8 5-9 5-10 5-11

More information

<4D6963726F736F667420506F776572506F696E74202D208376838C835B83938365815B835683878393312E707074205B8CDD8AB78382815B83685D>

<4D6963726F736F667420506F776572506F696E74202D208376838C835B83938365815B835683878393312E707074205B8CDD8AB78382815B83685D> i i vi ii iii iv v vi vii viii ix 2 3 4 5 6 7 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60

More information

RX600 & RX200シリーズ アプリケーションノート RX用仮想EEPROM

RX600 & RX200シリーズ アプリケーションノート RX用仮想EEPROM R01AN0724JU0170 Rev.1.70 MCU EEPROM RX MCU 1 RX MCU EEPROM VEE VEE API MCU MCU API RX621 RX62N RX62T RX62G RX630 RX631 RX63N RX63T RX210 R01AN0724JU0170 Rev.1.70 Page 1 of 33 1.... 3 1.1... 3 1.2... 3

More information

program.dvi

program.dvi 2001.06.19 1 programming semi ver.1.0 2001.06.19 1 GA SA 2 A 2.1 valuename = value value name = valuename # ; Fig. 1 #-----GA parameter popsize = 200 mutation rate = 0.01 crossover rate = 1.0 generation

More information

cpp4.dvi

cpp4.dvi 2017 c 4 C++ (4) C++, 41, 42, 1, 43,, 44 45, 41 (inheritance),, C++,, 100, 50, PCMCIA,,,,,,,,, 42 1 421 ( ), car 1 [List 41] 1: class car { 2: private: 3: std::string m model; // 4: std::string m maker;

More information

3 5 18 3 5000 1 2 7 8 120 1 9 1954 29 18 12 30 700 4km 1.5 100 50 6 13 5 99 93 34 17 2 2002 04 14 16 6000 12 57 60 1986 55 3 3 3 500 350 4 5 250 18 19 1590 1591 250 100 500 20 800 20 55 3 3 3 18 19 1590

More information

TopLink å SampleClient.java... 5 Ò readallsample() querysample() cachesample() Ç..

TopLink å SampleClient.java... 5 Ò readallsample() querysample() cachesample() Ç.. lê~åäé= qçéiáåâ= NMÖENMKNKPF Volume2 Creation Date: Mar 04, 2005 Last Update: Aug 22, 2005 Version 1.0 ...3... 3 TopLink å...4 1... 4... 4 SampleClient.java... 5 Ò... 8... 9... 10 readallsample()... 11

More information

/ SCHEDULE /06/07(Tue) / Basic of Programming /06/09(Thu) / Fundamental structures /06/14(Tue) / Memory Management /06/1

/ SCHEDULE /06/07(Tue) / Basic of Programming /06/09(Thu) / Fundamental structures /06/14(Tue) / Memory Management /06/1 I117 II I117 PROGRAMMING PRACTICE II 2 MEMORY MANAGEMENT 2 Research Center for Advanced Computing Infrastructure (RCACI) / Yasuhiro Ohara yasu@jaist.ac.jp / SCHEDULE 1. 2011/06/07(Tue) / Basic of Programming

More information

O(N) ( ) log 2 N

O(N) ( ) log 2 N 2005 11 21 1 1.1 2 O(N) () log 2 N 1.2 2 1 List 3-1 List 3-3 List 3-4? 3 3.1 3.1.1 List 2-1(p.70) 1 1 10 1 3.1.2 List 3-1(p.70-71) 1 1 2 1 2 2 1: 1 3 3.1.3 1 List 3-1(p.70-71) 2 #include stdlib.h

More information

untitled

untitled II 4 Yacc Lex 2005 : 0 1 Yacc 20 Lex 1 20 traverse 1 %% 2 [0-9]+ { yylval.val = atoi((char*)yytext); return NUM; 3 "+" { return + ; 4 "*" { return * ; 5 "-" { return - ; 6 "/" { return / ; 7 [ \t] { /*

More information

main.dvi

main.dvi 20 II 7. 1 409, 3255 e-mail: namba@faculty.chiba-u.jp 2 1 1 1 4 2 203 2 1 1 1 5 503 1 3 1 2 2 Web http://www.icsd2.tj.chiba-u.jp/~namba/lecture/ 1 2 1 5 501 1,, \,", 2000 7. : 1 1 CPU CPU 1 Intel Pentium

More information

untitled

untitled II yacc 005 : 1, 1 1 1 %{ int lineno=0; 3 int wordno=0; 4 int charno=0; 5 6 %} 7 8 %% 9 [ \t]+ { charno+=strlen(yytext); } 10 "\n" { lineno++; charno++; } 11 [^ \t\n]+ { wordno++; charno+=strlen(yytext);}

More information

i

i i ii iii iv v vi vii viii ix x xi ( ) 854.3 700.9 10 200 3,126.9 162.3 100.6 18.3 26.5 5.6/s ( ) ( ) 1949 8 12 () () ア イ ウ ) ) () () () () BC () () (

More information

連載講座 : 高生産並列言語を使いこなす (4) ゲーム木探索の並列化 田浦健次朗 東京大学大学院情報理工学系研究科, 情報基盤センター 目次 1 準備 問題の定義 αβ 法 16 2 αβ 法の並列化 概要 Young Brothers Wa

連載講座 : 高生産並列言語を使いこなす (4) ゲーム木探索の並列化 田浦健次朗 東京大学大学院情報理工学系研究科, 情報基盤センター 目次 1 準備 問題の定義 αβ 法 16 2 αβ 法の並列化 概要 Young Brothers Wa 連載講座 : 高生産並列言語を使いこなす (4) ゲーム木探索の並列化 田浦健次朗 東京大学大学院情報理工学系研究科, 情報基盤センター 目次 1 準備 16 1.1 問題の定義 16 1.2 αβ 法 16 2 αβ 法の並列化 17 2.1 概要 17 2.2 Young Brothers Wait Concept 17 2.3 段数による逐次化 18 2.4 適応的な待機 18 2. 強制終了

More information

01_OpenMP_osx.indd

01_OpenMP_osx.indd OpenMP* / 1 1... 2 2... 3 3... 5 4... 7 5... 9 5.1... 9 5.2 OpenMP* API... 13 6... 17 7... 19 / 4 1 2 C/C++ OpenMP* 3 Fortran OpenMP* 4 PC 1 1 9.0 Linux* Windows* Xeon Itanium OS 1 2 2 WEB OS OS OS 1 OS

More information

ストリーミング SIMD 拡張命令2 (SSE2) を使用した、倍精度浮動小数点ベクトルの最大/最小要素とそのインデックスの検出

ストリーミング SIMD 拡張命令2 (SSE2) を使用した、倍精度浮動小数点ベクトルの最大/最小要素とそのインデックスの検出 SIMD 2(SSE2) / 2.0 2000 7 : 248602J-001 01/10/30 1 305-8603 115 Fax: 0120-47-8832 * Copyright Intel Corporation 1999-2001 01/10/30 2 1...5 2...5 2.1...5 2.1.1...5 2.1.2...8 3...9 3.1...9 3.2...9 4...9

More information

III

III III 1 1 2 1 2 3 1 3 4 1 3 1 4 1 3 2 4 1 3 3 6 1 4 6 1 4 1 6 1 4 2 8 1 4 3 9 1 5 10 1 5 1 10 1 5 2 12 1 5 3 12 1 5 4 13 1 6 15 2 1 18 2 1 1 18 2 1 2 19 2 2 20 2 3 22 2 3 1 22 2 3 2 24 2 4 25 2 4 1 25 2

More information

iii iv v vi vii viii ix 1 1-1 1-2 1-3 2 2-1 3 3-1 3-2 3-3 3-4 4 4-1 4-2 5 5-1 5-2 5-3 5-4 5-5 5-6 5-7 6 6-1 6-2 6-3 6-4 6-5 6 6-1 6-2 6-3 6-4 6-5 7 7-1 7-2 7-3 7-4 7-5 7-6 7-7 7-8 7-9 7-10 7-11 8 8-1

More information

VB.NETコーディング標準

VB.NETコーディング標準 (C) Copyright 2002 Java ( ) VB.NET C# AS-IS extremeprogramming-jp@objectclub.esm.co.jp bata@gold.ocn.ne.jp Copyright (c) 2000,2001 Eiwa System Management, Inc. Object Club Kenji Hiranabe02/09/26 Copyright

More information

これわかWord2010_第1部_100710.indd

これわかWord2010_第1部_100710.indd i 1 1 2 3 6 6 7 8 10 10 11 12 12 12 13 2 15 15 16 17 17 18 19 20 20 21 ii CONTENTS 25 26 26 28 28 29 30 30 31 32 35 35 35 36 37 40 42 44 44 45 46 49 50 50 51 iii 52 52 52 53 55 56 56 57 58 58 60 60 iv

More information

パワポカバー入稿用.indd

パワポカバー入稿用.indd i 1 1 2 2 3 3 4 4 4 5 7 8 8 9 9 10 11 13 14 15 16 17 19 ii CONTENTS 2 21 21 22 25 26 32 37 38 39 39 41 41 43 43 43 44 45 46 47 47 49 52 54 56 56 iii 57 59 62 64 64 66 67 68 71 72 72 73 74 74 77 79 81 84

More information

これでわかるAccess2010

これでわかるAccess2010 i 1 1 1 2 2 2 3 4 4 5 6 7 7 9 10 11 12 13 14 15 17 ii CONTENTS 2 19 19 20 23 24 25 25 26 29 29 31 31 33 35 36 36 39 39 41 44 45 46 48 iii 50 50 52 54 55 57 57 59 61 63 64 66 66 67 70 70 73 74 74 77 77

More information

Java演習(4) -- 変数と型 --

Java演習(4)   -- 変数と型 -- 50 20 20 5 (20, 20) O 50 100 150 200 250 300 350 x (reserved 50 100 y 50 20 20 5 (20, 20) (1)(Blocks1.java) import javax.swing.japplet; import java.awt.graphics; (reserved public class Blocks1 extends

More information

exec.dvi

exec.dvi 2018 c 6, Mini-C C++ 6211 611, 61, print,,, (run ),,, (int ), 7, x, x "a" 3 "b" 4 "x" 10 (, ), x STL map 1 + 2, 1 2,, x = ;, 1, 2 x { 1 ; 2 ; ; m, if ( ) { 1 else { 2, 1,, 2 0, 1, 3 0, 2,,, main 6 1 ,,

More information

untitled

untitled i ii iii iv v 43 43 vi 43 vii T+1 T+2 1 viii 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 a) ( ) b) ( ) 51

More information

2

2 1 2 3 4 5 6 7 8 9 10 I II III 11 IV 12 V 13 VI VII 14 VIII. 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 _ 33 _ 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 VII 51 52 53 54 55 56 57 58 59

More information

2008chom.pdf

2008chom.pdf CHomP Pawe l Pilarczyk 1 CHomP Computational Homology Project [3] OS Windows Mac Unix Linux [3] CHomP [3] 2 3 CHomP CHomP 4 5 C++ [1] 2 CHomP 1 2 K 1 = { A 1 A 2 A 3, A 1 A 2, A 2 A 3, A 1 A 3, A 3 A 4,

More information

パソコン機能ガイド

パソコン機能ガイド PART12 ii iii iv v 1 2 3 4 5 vi vii viii ix P A R T 1 x P A R T 2 xi P A R T 3 xii xiii P A R T 1 2 3 1 4 5 1 6 1 1 2 7 1 2 8 1 9 10 1 11 12 1 13 1 2 3 4 14 1 15 1 2 3 16 4 1 1 2 3 17 18 1 19 20 1 1

More information

パソコン機能ガイド

パソコン機能ガイド PART2 iii ii iv v 1 2 3 4 5 vi vii viii ix P A R T 1 x P A R T 2 xi P A R T 3 xii xiii P A R T 1 2 1 3 4 1 5 6 1 2 1 1 2 7 8 9 1 10 1 11 12 1 13 1 2 3 14 4 1 1 2 3 15 16 1 17 1 18 1 1 2 19 20 1 21 1 22

More information

3 Powered by mod_perl, Apache & MySQL use Item; my $item = Item->new( id => 1, name => ' ', price => 1200,

3 Powered by mod_perl, Apache & MySQL use Item; my $item = Item->new( id => 1, name => ' ', price => 1200, WEB DB PRESS Vol.1 79 3 Powered by mod_perl, Apache & MySQL use Item; my $item = Item->new( id => 1, name => ' ', price => 1200, http://www.postgresql.org/http://www.jp.postgresql.org/ 80 WEB DB PRESS

More information

4.1 % 7.5 %

4.1 % 7.5 % 2018 (412837) 4.1 % 7.5 % Abstract Recently, various methods for improving computial performance have been proposed. One of these various methods is Multi-core. Multi-core can execute processes in parallel

More information

アルゴリズムとデータ構造1

アルゴリズムとデータ構造1 1 2007 6 26 26 (sakai.keiichi@kochi sakai.keiichi@kochi-tech.ac.jp) http://www.info.kochi-tech.ac.jp/k1sakai/lecture/alg/2007/index.html tech.ac.jp/k1sakai/lecture/alg/2007/index.html FIFO (46 ) head,

More information

平成18年版 男女共同参画白書

平成18年版 男女共同参画白書 i ii iii iv v vi vii viii ix 3 4 5 6 7 8 9 Column 10 11 12 13 14 15 Column 16 17 18 19 20 21 22 23 24 25 26 Column 27 28 29 30 Column 31 32 33 34 35 36 Column 37 Column 38 39 40 Column 41 42 43 44 45

More information

解きながら学ぶJava入門編

解きながら学ぶJava入門編 44 // class Negative { System.out.print(""); int n = stdin.nextint(); if (n < 0) System.out.println(""); -10 Ÿ 35 Ÿ 0 n if statement if ( ) if i f ( ) if n < 0 < true false true false boolean literalboolean

More information

Qt (Generic Containers) Java STL <QtAlgorithms> STL (Generic Algorithms) QList<T>, QLinkedList<T>, QVector<T>, QStack<T>, QQueue<T> QMap<Key,

Qt (Generic Containers) Java STL <QtAlgorithms> STL (Generic Algorithms) QList<T>, QLinkedList<T>, QVector<T>, QStack<T>, QQueue<T> QMap<Key, 1 5 5.1 Qt (Generic Containers) Java STL STL (Generic Algorithms) QList, QLinkedList, QVector, QStack, QQueue QMap, QMultiMap. QHash, QMultiHash

More information

困ったときのQ&A

困ったときのQ&A ii iii iv NEC Corporation 1998 v C O N T E N T S PART 1 vi vii viii ix x xi xii PART 2 xiii PART 3 xiv P A R T 1 3 1 2 PART 3 4 2 1 1 2 4 3 PART 1 4 5 5 6 PART 1 7 8 PART 1 9 1 2 3 1 2 3 10 PART 1 1 2

More information

Parametric Polymorphism

Parametric Polymorphism ML 2 2011/04/19 Parametric Polymorphism Type Polymorphism ? : val hd_int : int list - > int val hd_bool : bool list - > bool val hd_i_x_b : (int * bool) list - > int * bool etc. let hd_int = function (x

More information

活用ガイド (ソフトウェア編)

活用ガイド (ソフトウェア編) ii iii iv NEC Corporation 1998 v vi PA RT 1 vii PA RT 2 viii PA RT 3 PA RT 4 ix P A R T 1 2 3 1 4 5 1 1 2 1 2 3 4 6 1 2 3 4 5 7 1 6 7 8 1 9 1 10 1 2 3 4 5 6 7 8 9 10 11 11 1 12 12 1 13 1 1 14 2 3 4 5 1

More information

28 Docker Design and Implementation of Program Evaluation System Using Docker Virtualized Environment

28 Docker Design and Implementation of Program Evaluation System Using Docker Virtualized Environment 28 Docker Design and Implementation of Program Evaluation System Using Docker Virtualized Environment 1170288 2017 2 28 Docker,.,,.,,.,,.,. Docker.,..,., Web, Web.,.,.,, CPU,,. i ., OS..,, OS, VirtualBox,.,

More information

1... 1 2... 1 1... 1 2... 2 3... 2 4... 4 5... 4 6... 4 7... 22 8... 22 3... 22 1... 22 2... 23 3... 23 4... 24 5... 24 6... 25 7... 31 8... 32 9... 3

1... 1 2... 1 1... 1 2... 2 3... 2 4... 4 5... 4 6... 4 7... 22 8... 22 3... 22 1... 22 2... 23 3... 23 4... 24 5... 24 6... 25 7... 31 8... 32 9... 3 3 2620149 3 6 3 2 198812 21/ 198812 21 1 3 4 5 JISJIS X 0208 : 1997 JIS 4 JIS X 0213:2004 http://www.pref.hiroshima.lg.jp/site/monjokan/ 1... 1 2... 1 1... 1 2... 2 3... 2 4... 4 5... 4 6... 4 7... 22

More information

class IntCell { private int value ; int getvalue() {return value; private IntCell next; IntCell next() {return next; IntCell(int value) {this.value =

class IntCell { private int value ; int getvalue() {return value; private IntCell next; IntCell next() {return next; IntCell(int value) {this.value = Part2-1-3 Java (*) (*).class Java public static final 1 class IntCell { private int value ; int getvalue() {return value; private IntCell next; IntCell next() {return next; IntCell(int value) {this.value

More information

C++0x

C++0x C++0x 言語の未来を語る 高橋晶 ( アキラ ) Blog: Faith and Brave C++ で遊ぼう Agenda What s C++0x Angle Bracket Initializer List auto decltype Delegating Constructor Extending sizeof Raw String Literal Defaulted and Deleted

More information

SystemC言語概論

SystemC言語概論 SystemC CPU S/W 2004/01/29 4 SystemC 1 SystemC 2.0.1 CPU S/W 3 ISS SystemC Co-Simulation 2004/01/29 4 SystemC 2 ISS SystemC Co-Simulation GenericCPU_Base ( ) GenericCPU_ISS GenericCPU_Prog GenericCPU_CoSim

More information

~~~~~~~~~~~~~~~~~~ wait Call CPU time 1, latch: library cache 7, latch: library cache lock 4, job scheduler co

~~~~~~~~~~~~~~~~~~ wait Call CPU time 1, latch: library cache 7, latch: library cache lock 4, job scheduler co 072 DB Magazine 2007 September ~~~~~~~~~~~~~~~~~~ wait Call CPU time 1,055 34.7 latch: library cache 7,278 750 103 24.7 latch: library cache lock 4,194 465 111 15.3 job scheduler coordinator slave wait

More information

やさしいJavaプログラミング -Great Ideas for Java Programming サンプルPDF

やさしいJavaプログラミング -Great Ideas for Java Programming サンプルPDF pref : 2004/6/5 (11:8) pref : 2004/6/5 (11:8) pref : 2004/6/5 (11:8) 3 5 14 18 21 23 23 24 28 29 29 31 32 34 35 35 36 38 40 44 44 45 46 49 49 50 pref : 2004/6/5 (11:8) 50 51 52 54 55 56 57 58 59 60 61

More information

1... 1 1... 1 2... 1 3... 1 4... 4 5... 7 6... 7 7... 12 8... 12 9... 13 10... 13 11... 13 12... 14 2... 14 1... 14 2... 16 3... 18 4... 19 5... 19 6.

1... 1 1... 1 2... 1 3... 1 4... 4 5... 7 6... 7 7... 12 8... 12 9... 13 10... 13 11... 13 12... 14 2... 14 1... 14 2... 16 3... 18 4... 19 5... 19 6. 3 2620149 1 3 8 3 2 198809 1/1 198809 1 1 3 4 5 JISJIS X 0208 : 1997 JIS 4 JIS X 0213:2004 http://www.pref.hiroshima.lg.jp/site/monjokan/ 1... 1 1... 1 2... 1 3... 1 4... 4 5... 7 6... 7 7... 12 8... 12

More information

新・明解C言語 実践編

新・明解C言語 実践編 第 1 章 見 21 1-1 見えないエラー 見 List 1-1 "max2x1.h" a, b max2 List 1-1 chap01/max2x1.h max2 "max2x1.h" #define max2(a, b) ((a) > (b)? (a) : (b)) max2 List 1-2 List 1-2 chap01/max2x1test.c max2 #include

More information

,,,,., C Java,,.,,.,., ,,.,, i

,,,,., C Java,,.,,.,., ,,.,, i 24 Development of the programming s learning tool for children be derived from maze 1130353 2013 3 1 ,,,,., C Java,,.,,.,., 1 6 1 2.,,.,, i Abstract Development of the programming s learning tool for children

More information

ストラドプロシージャの呼び出し方

ストラドプロシージャの呼び出し方 Release10.5 Oracle DataServer Informix MS SQL NXJ SQL JDBC Java JDBC NXJ : NXJ JDBC / NXJ EXEC SQL [USING CONNECTION ] CALL [.][.] ([])

More information

1 # include < stdio.h> 2 # include < string.h> 3 4 int main (){ 5 char str [222]; 6 scanf ("%s", str ); 7 int n= strlen ( str ); 8 for ( int i=n -2; i

1 # include < stdio.h> 2 # include < string.h> 3 4 int main (){ 5 char str [222]; 6 scanf (%s, str ); 7 int n= strlen ( str ); 8 for ( int i=n -2; i ABC066 / ARC077 writer: nuip 2017 7 1 For International Readers: English editorial starts from page 8. A : ringring a + b b + c a + c a, b, c a + b + c 1 # include < stdio.h> 2 3 int main (){ 4 int a,

More information

:30 12:00 I. I VI II. III. IV. a d V. VI

:30 12:00 I. I VI II. III. IV. a d V. VI 2017 2017 08 03 10:30 12:00 I. I VI II. III. IV. a d V. VI. 80 100 60 1 I. Backus-Naur BNF X [ S ] a S S ; X X X, S [, a, ], ; BNF X (parse tree) (1) [a;a] (2) [[a]] (3) [a;[a]] (4) [[a];a] : [a] X 2 222222

More information

RubyKaigi2009 COBOL

RubyKaigi2009 COBOL RubyKaigi2009 COBOL seki@druby.org 3360 Pragmatic Bookshelf druby Web $32.00 International Journal of PARALLEL PROGRAMING !? MapReduce Rinda (map, reduce) map reduce key value [, ] [, ID] map()

More information

# let st1 = {name = "Taro Yamada"; id = };; val st1 : student = {name="taro Yamada"; id=123456} { 1 = 1 ;...; n = n } # let string_of_student {n

# let st1 = {name = Taro Yamada; id = };; val st1 : student = {name=taro Yamada; id=123456} { 1 = 1 ;...; n = n } # let string_of_student {n II 6 / : 2001 11 21 (OCaml ) 1 (field) name id type # type student = {name : string; id : int};; type student = { name : string; id : int; } student {} type = { 1 : 1 ;...; n : n } { 1 = 1 ;...; n = n

More information

org/ghc/ Windows Linux RPM 3.2 GHCi GHC gcc javac ghc GHCi(ghci) GHCi Prelude> GHCi :load file :l file :also file :a file :reload :r :type expr :t exp

org/ghc/ Windows Linux RPM 3.2 GHCi GHC gcc javac ghc GHCi(ghci) GHCi Prelude> GHCi :load file :l file :also file :a file :reload :r :type expr :t exp 3 Haskell Haskell Haskell 1. 2. 3. 4. 5. 1. 2. 3. 4. 5. 6. C Java 3.1 Haskell Haskell GHC (Glasgow Haskell Compiler 1 ) GHC Haskell GHC http://www.haskell. 1 Guarded Horn Clauses III - 1 org/ghc/ Windows

More information

™…

™… i 1 1 1 2 3 5 5 6 7 9 10 11 13 13 14 15 15 16 17 18 20 20 20 21 22 ii CONTENTS 23 24 26 27 2 31 31 32 32 33 34 37 37 38 39 39 40 42 42 43 44 45 48 50 51 51 iii 54 57 58 60 60 62 64 64 67 69 70 iv 70 71

More information

ohp11.dvi

ohp11.dvi 19 11 ( ) 2019.4.20 1 / ( ) n O(n 2 ) O(n 2 ) ( ) 1 d n 1 n logn O(nlogn) n ( n logn C ) 2 ( ) ( merge) 2 1 1 3 1 4 5 4 2 3 7 9 7 1 2 3 4 5 7 9 1: 2 ivec merge 3 ( ) (2) int *ivec_new(int size) { int *a

More information

r11.dvi

r11.dvi 19 11 ( ) 2019.4.20 1 / 1.1 ( n n O(n 2 O(n 2 ) ( 1 d n 1 n logn O(nlogn n ( n logn C 1.2 ( ( merge 2 1 1 3 1 4 5 4 2 3 7 9 7 1 2 3 4 5 7 9 1: 2 ivec merge int *ivec_new(int size) { int *a = (int*)malloc((size+1)

More information

Green with White Lines

Green with White Lines 各種コンテナの実装と性能 Qt #4 勉強会福岡 @ kikairoya About Twitter: @kikairoya 宮崎県都城市から来ました 本職 : 精密機械設計 組込機器開発 C++ とか出来ます Qt わかりません Abstruct STL コンテナと Qt コンテナの比較 データ構造 パフォーマンス 安全性 インタフェース おまけで Boost コンテナも STL Containers

More information