jdk

Форк
0
/
avx2-linux-qsort.cpp 
66 строк · 2.4 Кб
1
/*
2
 * Copyright (c) 2023 Intel Corporation. All rights reserved.
3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
 *
5
 * This code is free software; you can redistribute it and/or modify it
6
 * under the terms of the GNU General Public License version 2 only, as
7
 * published by the Free Software Foundation.
8
 *
9
 * This code is distributed in the hope that it will be useful, but WITHOUT
10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12
 * version 2 for more details (a copy is included in the LICENSE file that
13
 * accompanied this code).
14
 *
15
 * You should have received a copy of the GNU General Public License version
16
 * 2 along with this work; if not, write to the Free Software Foundation,
17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
 *
19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
 * or visit www.oracle.com if you need additional information or have any
21
 * questions.
22
 *
23
 */
24

25
#include "simdsort-support.hpp"
26
#ifdef __SIMDSORT_SUPPORTED_LINUX
27

28
#pragma GCC target("avx2")
29
#include "avx2-32bit-qsort.hpp"
30
#include "classfile_constants.h"
31

32

33
#define DLL_PUBLIC __attribute__((visibility("default")))
34
#define INSERTION_SORT_THRESHOLD_32BIT 16
35

36
extern "C" {
37

38
    DLL_PUBLIC void avx2_sort(void *array, int elem_type, int32_t from_index, int32_t to_index) {
39
        switch(elem_type) {
40
            case JVM_T_INT:
41
                avx2_fast_sort((int32_t*)array, from_index, to_index, INSERTION_SORT_THRESHOLD_32BIT);
42
                break;
43
            case JVM_T_FLOAT:
44
                avx2_fast_sort((float*)array, from_index, to_index, INSERTION_SORT_THRESHOLD_32BIT);
45
                break;
46
            default:
47
                assert(false, "Unexpected type");
48
        }
49
    }
50

51
    DLL_PUBLIC void avx2_partition(void *array, int elem_type, int32_t from_index, int32_t to_index, int32_t *pivot_indices, int32_t index_pivot1, int32_t index_pivot2) {
52
        switch(elem_type) {
53
            case JVM_T_INT:
54
                avx2_fast_partition((int32_t*)array, from_index, to_index, pivot_indices, index_pivot1, index_pivot2);
55
                break;
56
            case JVM_T_FLOAT:
57
                avx2_fast_partition((float*)array, from_index, to_index, pivot_indices, index_pivot1, index_pivot2);
58
                break;
59
            default:
60
                assert(false, "Unexpected type");
61
        }
62
    }
63

64
}
65

66
#endif

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.