• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

bernardladenthin / BitcoinAddressFinder / #308

28 Apr 2025 10:01PM UTC coverage: 68.174% (-0.7%) from 68.832%
#308

push

bernardladenthin
Refactor OpenCL handling for device endianness and dynamic platform selection

22 of 76 new or added lines in 10 files covered. (28.95%)

1 existing line in 1 file now uncovered.

1221 of 1791 relevant lines covered (68.17%)

0.68 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/net/ladenthin/bitcoinaddressfinder/opencl/OpenCLPlatformSelector.java
1
// @formatter:off
2
/**
3
 * Copyright 2025 Bernard Ladenthin bernard.ladenthin@gmail.com
4
 *
5
 * Licensed under the Apache License, Version 2.0 (the "License");
6
 * you may not use this file except in compliance with the License.
7
 * You may obtain a copy of the License at
8
 *
9
 *    http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 *
17
 */
18
// @formatter:on
19
package net.ladenthin.bitcoinaddressfinder.opencl;
20

21
import java.util.List;
22

NEW
23
public class OpenCLPlatformSelector {
×
24

25
    /**
26
     * Selects an OpenCLDevice based on the platform index and device type from the given list of platforms.
27
     *
28
     * @param platforms The list of available OpenCL platforms
29
     * @param platformIndex The index of the platform to select
30
     * @param deviceType The OpenCL device type (e.g., CL_DEVICE_TYPE_GPU)
31
     * @param deviceIndex The index of the device within the platform
32
     * @return A selected OpenCLDeviceSelection containing platform, device, and context properties
33
     */
34
    public static OpenCLDeviceSelection select(List<OpenCLPlatform> platforms, int platformIndex, long deviceType, int deviceIndex) {
NEW
35
        if (platformIndex < 0 || platformIndex >= platforms.size()) {
×
NEW
36
            throw new IllegalArgumentException("Invalid platform index: " + platformIndex);
×
37
        }
38
        
NEW
39
        OpenCLPlatform selectedPlatform = platforms.get(platformIndex);
×
40
        
NEW
41
        List<OpenCLDevice> matchingDevices = selectedPlatform.openCLDevices().stream()
×
NEW
42
            .filter(device -> (device.deviceType() & deviceType) != 0)
×
NEW
43
            .toList();
×
44

NEW
45
        if (deviceIndex < 0 || deviceIndex >= matchingDevices.size()) {
×
NEW
46
            throw new IllegalArgumentException("Invalid device index: " + deviceIndex + " for deviceType: " + deviceType);
×
47
        }
48
        
NEW
49
        OpenCLDevice selectedDevice = matchingDevices.get(deviceIndex);
×
50
        
NEW
51
        return new OpenCLDeviceSelection(selectedPlatform, selectedDevice, selectedPlatform.contextProperties());
×
52
    }
53
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc