Ignore:
Timestamp:
Dec 20, 2016 6:02:42 AM (7 years ago)
Author:
wojciech
Children:
e29c798
Parents:
33844bf
Message:

Handling for PYOPENCL_CTX for multiple platforms added

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/perspectives/fitting/gpu_options.py

    r4139147 rebaaf05  
    3838        #Check if SAS_OPENCL is already set 
    3939        self.sas_opencl = os.environ.get("SAS_OPENCL","") 
    40         for index, clopt in enumerate(clinfo): 
    41             button = wx.CheckBox(self.panel1, -1, label=clopt, name=clopt) 
     40        for clopt in clinfo: 
     41            print("clopt",clopt) 
     42            button = wx.CheckBox(self.panel1, -1, label=clopt[1], name=clopt[1]) 
    4243 
    4344            if clopt != "No OpenCL": 
    44                 self.option_button[clopt] = str(index) 
    45                 if self.sas_opencl == str(index): 
     45                self.option_button[clopt[1]] = clopt[0] 
     46                if self.sas_opencl == clopt[0]: 
    4647                    button.SetValue(1) 
    4748            else: 
     
    102103        try: 
    103104            import pyopencl as cl 
    104             for platform in cl.get_platforms(): 
     105            platforms = cl.get_platforms() 
     106            p_index = 0 
     107            for platform in platforms: 
     108                d_index = 0 
    105109                for device in platform.get_devices(): 
    106                     clinfo.append(":".join([platform.name,device.name])) 
     110                    combined_index = ":".join(str(p_index),str(d_index)) \ 
     111                        if len(platforms) > 1 else str(d_index) 
     112                    clinfo.append((combined_index, ":".join([platform.name,device.name]))) 
     113                    d_index+=1 
     114                p_index+=1 
    107115        except ImportError: 
    108116            warnings.warn("pyopencl import failed. Using only CPU computations") 
    109117 
    110         clinfo.append("No OpenCL") 
     118        clinfo.append(("None","No OpenCL")) 
    111119        return clinfo 
    112120 
Note: See TracChangeset for help on using the changeset viewer.