opencl-bindings 1.0.0pre2 → 1.0.0pre3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aea7dd9c7cc8149f8f2fc81b86edb83da2d71343
4
- data.tar.gz: 1a14cd6169148349dd56c1fba9f9322fea6b924a
3
+ metadata.gz: d8cf2f7b42d28415dce84ced6ebfab2d1799aa37
4
+ data.tar.gz: 37e5a5b0b377d61c94e7df9b5f9e9ce235298b16
5
5
  SHA512:
6
- metadata.gz: fb1debe697a01f8c984c79abaf8f7d6a03d28d35b08ba857f1443aecff055ac2ec2628c8495f764ee84086d9c4e6aba2078ab10a925048045cd6eceb90cd7a0c
7
- data.tar.gz: b350bd39fa361a6e54438e7a60365786a9b4c8deac95cc5b63dfa62ab862d3ec85b680fab290175c78b7f97c60b7496df5e5118ebf05d49180cc21ddb7a5fc80
6
+ metadata.gz: e0b55bca3fe471829448760b6630c7120aaa2290a0cdf22ab7119cf89922c3de328175e7b4640d16494e4ec13f7cb9dbca6eafa056b2b854963c947f7bd49bec
7
+ data.tar.gz: 996d769c1593283e05b3c7eabd2d14a9238596fe3e0b878ec67543e8e0f854183009caa86bbeecb0ff99442908d99d13d5f4ec5158ba3d973331191fcbf8e489
data/ChangeLog CHANGED
@@ -1,3 +1,8 @@
1
+ 2015-11-26 vaiorabbit <http://twitter.com/vaiorabbit>
2
+
3
+ * sample/Mandelbrot/mandelbrot_prof.rb, mandelbrot_prof.cl: Added.
4
+ * sample/util/clu.rb (CLUEvent.getEventProfilingInfo): Added.
5
+
1
6
  2015-11-23 vaiorabbit <http://twitter.com/vaiorabbit>
2
7
 
3
8
  * sample/report_env.rb: Added.
data/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  A Ruby binding for OpenCL 1.2
6
6
 
7
7
  * Created : 2015-10-25
8
- * Last modified : 2015-11-23
8
+ * Last modified : 2015-11-26
9
9
 
10
10
 
11
11
  ## Features ##
@@ -964,7 +964,7 @@ module OpenCL
964
964
 
965
965
  # Profiling APIs
966
966
 
967
- # cl_event : event
967
+ # cl_event : event
968
968
  # cl_profiling_info : param_name
969
969
  # size_t : param_value_size
970
970
  # void * : param_value
@@ -94,8 +94,8 @@ $enum2pack = {
94
94
  OpenCL::CL_DEVICE_VENDOR_ID => "L",
95
95
  OpenCL::CL_DEVICE_MAX_COMPUTE_UNITS => "L",
96
96
  OpenCL::CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS => "L",
97
- OpenCL::CL_DEVICE_MAX_WORK_GROUP_SIZE => "L",
98
- OpenCL::CL_DEVICE_MAX_WORK_ITEM_SIZES => "L3",
97
+ OpenCL::CL_DEVICE_MAX_WORK_GROUP_SIZE => "Q",
98
+ OpenCL::CL_DEVICE_MAX_WORK_ITEM_SIZES => "Q3",
99
99
  OpenCL::CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR => "L",
100
100
  OpenCL::CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT => "L",
101
101
  OpenCL::CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT => "L",
@@ -107,13 +107,13 @@ $enum2pack = {
107
107
  OpenCL::CL_DEVICE_MAX_READ_IMAGE_ARGS => "L",
108
108
  OpenCL::CL_DEVICE_MAX_WRITE_IMAGE_ARGS => "L",
109
109
  OpenCL::CL_DEVICE_MAX_MEM_ALLOC_SIZE => "L",
110
- OpenCL::CL_DEVICE_IMAGE2D_MAX_WIDTH => "L",
111
- OpenCL::CL_DEVICE_IMAGE2D_MAX_HEIGHT => "L",
112
- OpenCL::CL_DEVICE_IMAGE3D_MAX_WIDTH => "L",
113
- OpenCL::CL_DEVICE_IMAGE3D_MAX_HEIGHT => "L",
114
- OpenCL::CL_DEVICE_IMAGE3D_MAX_DEPTH => "L",
110
+ OpenCL::CL_DEVICE_IMAGE2D_MAX_WIDTH => "Q",
111
+ OpenCL::CL_DEVICE_IMAGE2D_MAX_HEIGHT => "Q",
112
+ OpenCL::CL_DEVICE_IMAGE3D_MAX_WIDTH => "Q",
113
+ OpenCL::CL_DEVICE_IMAGE3D_MAX_HEIGHT => "Q",
114
+ OpenCL::CL_DEVICE_IMAGE3D_MAX_DEPTH => "Q",
115
115
  OpenCL::CL_DEVICE_IMAGE_SUPPORT => "cl_bool",
116
- OpenCL::CL_DEVICE_MAX_PARAMETER_SIZE => "L",
116
+ OpenCL::CL_DEVICE_MAX_PARAMETER_SIZE => "Q",
117
117
  OpenCL::CL_DEVICE_MAX_SAMPLERS => "L",
118
118
  OpenCL::CL_DEVICE_MEM_BASE_ADDR_ALIGN => "L",
119
119
  OpenCL::CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE => "L",
@@ -127,7 +127,7 @@ $enum2pack = {
127
127
  OpenCL::CL_DEVICE_LOCAL_MEM_TYPE => "L",
128
128
  OpenCL::CL_DEVICE_LOCAL_MEM_SIZE => "L",
129
129
  OpenCL::CL_DEVICE_ERROR_CORRECTION_SUPPORT => "cl_bool",
130
- OpenCL::CL_DEVICE_PROFILING_TIMER_RESOLUTION => "L",
130
+ OpenCL::CL_DEVICE_PROFILING_TIMER_RESOLUTION => "Q",
131
131
  OpenCL::CL_DEVICE_ENDIAN_LITTLE => "cl_bool",
132
132
  OpenCL::CL_DEVICE_AVAILABLE => "cl_bool",
133
133
  OpenCL::CL_DEVICE_COMPILER_AVAILABLE => "cl_bool",
@@ -153,8 +153,8 @@ $enum2pack = {
153
153
  OpenCL::CL_DEVICE_OPENCL_C_VERSION => "Z*",
154
154
  OpenCL::CL_DEVICE_LINKER_AVAILABLE => "cl_bool",
155
155
  OpenCL::CL_DEVICE_BUILT_IN_KERNELS => "Z*",
156
- OpenCL::CL_DEVICE_IMAGE_MAX_BUFFER_SIZE => "L",
157
- OpenCL::CL_DEVICE_IMAGE_MAX_ARRAY_SIZE => "L",
156
+ OpenCL::CL_DEVICE_IMAGE_MAX_BUFFER_SIZE => "Q",
157
+ OpenCL::CL_DEVICE_IMAGE_MAX_ARRAY_SIZE => "Q",
158
158
  OpenCL::CL_DEVICE_PARENT_DEVICE => "Q",
159
159
  OpenCL::CL_DEVICE_PARTITION_MAX_SUB_DEVICES => "L",
160
160
  OpenCL::CL_DEVICE_PARTITION_PROPERTIES => "L",
@@ -162,7 +162,7 @@ $enum2pack = {
162
162
  OpenCL::CL_DEVICE_PARTITION_TYPE => "L",
163
163
  OpenCL::CL_DEVICE_REFERENCE_COUNT => "L",
164
164
  OpenCL::CL_DEVICE_PREFERRED_INTEROP_USER_SYNC => "L",
165
- OpenCL::CL_DEVICE_PRINTF_BUFFER_SIZE => "L",
165
+ OpenCL::CL_DEVICE_PRINTF_BUFFER_SIZE => "Q",
166
166
  OpenCL::CL_DEVICE_IMAGE_PITCH_ALIGNMENT => "L",
167
167
  OpenCL::CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT => "L"
168
168
  }
@@ -255,8 +255,8 @@ end
255
255
  class CLUContext
256
256
  attr_reader :context
257
257
 
258
- def initialize
259
- @context = nil # cl_context
258
+ def initialize(h = nil)
259
+ @context = h # cl_context
260
260
  end
261
261
 
262
262
  def handle
@@ -411,8 +411,8 @@ end
411
411
  class CLUMemory
412
412
  attr_reader :mem # cl_mem
413
413
 
414
- def initialize
415
- @mem = nil
414
+ def initialize(h = nil)
415
+ @mem = h
416
416
  end
417
417
 
418
418
  def handle
@@ -691,8 +691,8 @@ end
691
691
  class CLUCommandQueue
692
692
  attr_reader :command_queue # cl_command_queue
693
693
 
694
- def initialize
695
- @command_queue = nil # cl_command_queue
694
+ def initialize(h = nil)
695
+ @command_queue = h # cl_command_queue
696
696
  end
697
697
 
698
698
  def handle
@@ -720,7 +720,7 @@ class CLUCommandQueue
720
720
 
721
721
  def self.newCommandQueue(context, device, properties = 0, error_info: nil)
722
722
  obj = CLUCommandQueue.new
723
- ret = obj.createCommandQueue(context, device, 0, error_info: error_info)
723
+ ret = obj.createCommandQueue(context, device, properties, error_info: error_info)
724
724
  return ret == nil ? nil : obj
725
725
  end
726
726
 
@@ -1134,8 +1134,8 @@ end
1134
1134
  class CLUProgram
1135
1135
  attr_reader :program # cl_program
1136
1136
 
1137
- def initialize
1138
- @program = nil
1137
+ def initialize(h = nil)
1138
+ @program = h
1139
1139
  end
1140
1140
 
1141
1141
  def handle
@@ -1216,8 +1216,8 @@ end
1216
1216
  class CLUKernel
1217
1217
  attr_reader :kernel, :name # cl_kernel and the name of '__kernel' entry point
1218
1218
 
1219
- def initialize
1220
- @kernel = nil
1219
+ def initialize(h = nil)
1220
+ @kernel = h
1221
1221
  @name = nil
1222
1222
  end
1223
1223
 
@@ -1497,6 +1497,226 @@ end
1497
1497
 
1498
1498
  ################################################################################
1499
1499
 
1500
+ class CLUEvent
1501
+ attr_reader :event # cl_event
1502
+
1503
+ def initialize(h = nil)
1504
+ @event = h
1505
+ end
1506
+
1507
+ def handle
1508
+ @event
1509
+ end
1510
+
1511
+ # const cl_event * : event_list
1512
+ def self.waitForEvents(event_list)
1513
+ event_list.collect! {|event| event.kind_of?(CLUEvent) ? event.handle.to_i : event}
1514
+ # cl_uint : num_events
1515
+ num_events = event_list.length
1516
+
1517
+ err = OpenCL.clWaitForEvents(num_events, event_list.pack("Q*"))
1518
+ return err
1519
+ end
1520
+
1521
+ def wait(event: @event)
1522
+ return self.class.waitForEvents([event])
1523
+ end
1524
+
1525
+ # cl_context : context
1526
+ def createUserEvent(context, error_info: nil)
1527
+ context = context.handle if context.kind_of? CLUContext
1528
+ errcode_ret_buf = ' ' * 4
1529
+
1530
+ cl_event = OpenCL.clCreateUserEvent(context, errcode_ret_buf)
1531
+ errcode_ret = errcode_ret_buf.unpack("l")[0]
1532
+ error_info << errcode_ret if error_info != nil
1533
+
1534
+ if errcode_ret == OpenCL::CL_SUCCESS
1535
+ @event = cl_event
1536
+ return @event
1537
+ else
1538
+ return nil
1539
+ end
1540
+ end
1541
+
1542
+ def self.newUserEvent(context, error_info: nil)
1543
+ obj = CLUEvent.new
1544
+ ret = obj.createUserEvent(context, error_info: error_info)
1545
+ return ret == nil ? nil : obj
1546
+ end
1547
+
1548
+ # cl_event : event
1549
+ # cl_int : execution_status
1550
+ def setUserEventStatus(execution_status, event: @event)
1551
+ err = OpenCL.clSetUserEventStatus(event, execution_status)
1552
+ return err
1553
+ end
1554
+
1555
+ # cl_event : event
1556
+ # cl_int : command_exec_callback_type
1557
+ # void * : pfn_notify(cl_program, void*)
1558
+ # void * : user_data
1559
+ def setEventCallback(command_exec_callback_type, pfn_notify, user_data, event: @event)
1560
+ err = OpenCL.clSetEventCallback(event, command_exec_callback_type, pfn_notify, user_data)
1561
+ return err
1562
+ end
1563
+
1564
+ # cl_event : event
1565
+ def retainEvent(event: @event)
1566
+ return OpenCL.clRetainEvent(event)
1567
+ end
1568
+
1569
+ alias_method :retain, :retainEvent
1570
+
1571
+ # cl_event : event
1572
+ def releaseEvent(event: @event)
1573
+ return OpenCL.clReleaseEvent(event)
1574
+ end
1575
+
1576
+ alias_method :release, :releaseEvent
1577
+
1578
+ # cl_event : event
1579
+ # cl_event_info : param_name
1580
+ def getEventInfo(param_name, event: @event, error_info: nil)
1581
+ # size_t : param_value_size
1582
+ # void * : param_value
1583
+ # size_t * : param_value_size_ret
1584
+ param_value_buf_length = 1024
1585
+ param_value_buf = ' ' * param_value_buf_length
1586
+ param_value_size_ret_buf = ' ' * 4
1587
+
1588
+ err = OpenCL.clGetEventInfo(event, param_name, param_value_buf_length, param_value_buf, param_value_size_ret_buf)
1589
+ error_info << err if error_info != nil
1590
+
1591
+ param_value_size_ret = param_value_size_ret_buf.unpack("L")[0]
1592
+
1593
+ unpack_format = @@event_info_param2unpack[param_name]
1594
+ return param_value_buf.unpack(unpack_format)[0]
1595
+ end
1596
+
1597
+ @@event_info_param2unpack = {
1598
+ OpenCL::CL_EVENT_COMMAND_QUEUE => "Q",
1599
+ OpenCL::CL_EVENT_CONTEXT => "Q",
1600
+ OpenCL::CL_EVENT_COMMAND_TYPE => "L",
1601
+ OpenCL::CL_EVENT_COMMAND_EXECUTION_STATUS => "l",
1602
+ OpenCL::CL_EVENT_REFERENCE_COUNT => "L",
1603
+ }
1604
+
1605
+ # cl_event : event
1606
+ # cl_profiling_info : param_name
1607
+ def getEventProfilingInfo(param_name, event: @event, error_info: nil)
1608
+ # size_t : param_value_size
1609
+ # void * : param_value
1610
+ # size_t * : param_value_size_ret
1611
+ param_value_buf_length = 1024
1612
+ param_value_buf = ' ' * param_value_buf_length
1613
+ param_value_size_ret_buf = ' ' * 4
1614
+
1615
+ err = OpenCL.clGetEventProfilingInfo(event, param_name, param_value_buf_length, param_value_buf, param_value_size_ret_buf)
1616
+ error_info << err if error_info != nil
1617
+
1618
+ param_value_size_ret = param_value_size_ret_buf.unpack("L")[0]
1619
+
1620
+ unpack_format = @@event_profinfo_param2unpack[param_name]
1621
+ return param_value_buf.unpack(unpack_format)[0]
1622
+ end
1623
+
1624
+ @@event_profinfo_param2unpack = {
1625
+ OpenCL::CL_PROFILING_COMMAND_QUEUED => "Q",
1626
+ OpenCL::CL_PROFILING_COMMAND_SUBMIT => "Q",
1627
+ OpenCL::CL_PROFILING_COMMAND_START => "Q",
1628
+ OpenCL::CL_PROFILING_COMMAND_END => "Q",
1629
+ }
1630
+ end
1631
+
1632
+ ################################################################################
1633
+
1634
+ class CLUSampler
1635
+ attr_reader :sampler # cl_sampler
1636
+
1637
+ def initialize(h = nil)
1638
+ @sampler = h
1639
+ end
1640
+
1641
+ def handle
1642
+ @sampler
1643
+ end
1644
+
1645
+ # cl_context : context
1646
+ # cl_bool : normalized_coords
1647
+ # cl_addressing_mode : addressing_mode
1648
+ # cl_filter_mode : filter_mode
1649
+ def createSampler(context, normalized_coords, addressing_mode, filter_mode, error_info: nil)
1650
+ context = context.handle if context.kind_of? CLUContext
1651
+ errcode_ret_buf = ' ' * 4
1652
+
1653
+ cl_smp = OpenCL.clCreateSampler(context, normalized_coords, addressing_mode, filter_mode, errcode_ret_buf)
1654
+ errcode_ret = errcode_ret_buf.unpack("l")[0]
1655
+ error_info << errcode_ret if error_info != nil
1656
+
1657
+ if errcode_ret == OpenCL::CL_SUCCESS
1658
+ @sampler = cl_smp
1659
+ return @sampler
1660
+ else
1661
+ return nil
1662
+ end
1663
+ end
1664
+
1665
+ def self.newSampler(context, normalized_coords, addressing_mode, filter_mode, error_info: nil)
1666
+ obj = CLUSampler.new
1667
+ ret = obj.createSampler(context, normalized_coords, addressing_mode, filter_mode, error_info: error_info)
1668
+ return ret == nil ? nil : obj
1669
+ end
1670
+
1671
+ # cl_sampler : sampler
1672
+ def retainSampler(sampler: @sampler)
1673
+ return OpenCL.clRetainSampler(sampler)
1674
+ end
1675
+
1676
+ alias_method :retain, :retainSampler
1677
+
1678
+ # cl_sampler : sampler
1679
+ def releaseSampler(sampler: @sampler)
1680
+ return OpenCL.clReleaseSampler(sampler)
1681
+ end
1682
+
1683
+ alias_method :release, :releaseSampler
1684
+
1685
+ # cl_sampler : sampler
1686
+ # cl_sampler_info : param_name
1687
+ def getSamplerInfo(param_name, sampler: @sampler, error_info: nil)
1688
+ # size_t : param_value_size
1689
+ # void * : param_value
1690
+ # size_t * : param_value_size_ret
1691
+ param_value_buf_length = 1024
1692
+ param_value_buf = ' ' * param_value_buf_length
1693
+ param_value_size_ret_buf = ' ' * 4
1694
+
1695
+ err = OpenCL.clGetSamplerInfo(sampler, param_name, param_value_buf_length, param_value_buf, param_value_size_ret_buf)
1696
+ error_info << err if error_info != nil
1697
+
1698
+ param_value_size_ret = param_value_size_ret_buf.unpack("L")[0]
1699
+
1700
+ unpack_format = @@param2unpack[param_name]
1701
+ case unpack_format
1702
+ when "cl_bool"
1703
+ return param_value_buf.unpack("L")[0] == 0 ? false : true
1704
+ else
1705
+ return param_value_buf.unpack(unpack_format)[0]
1706
+ end
1707
+ end
1708
+
1709
+ @@param2unpack = {
1710
+ OpenCL::CL_SAMPLER_REFERENCE_COUNT => "L",
1711
+ OpenCL::CL_SAMPLER_CONTEXT => "Q",
1712
+ OpenCL::CL_SAMPLER_NORMALIZED_COORDS => "cl_bool",
1713
+ OpenCL::CL_SAMPLER_ADDRESSING_MODE => "L",
1714
+ OpenCL::CL_SAMPLER_FILTER_MODE => "L",
1715
+ }
1716
+ end
1717
+
1718
+ ################################################################################
1719
+
1500
1720
  class CLU
1501
1721
 
1502
1722
  @@image_format = {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opencl-bindings
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0pre2
4
+ version: 1.0.0pre3
5
5
  platform: ruby
6
6
  authors:
7
7
  - vaiorabbit
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-23 00:00:00.000000000 Z
11
+ date: 2015-11-26 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  Ruby bindings for OpenCL 1.2 using Fiddle (For MRI >= 2.0.0).