jdk
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_LINUX27
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 1635
36extern "C" {37
38DLL_PUBLIC void avx2_sort(void *array, int elem_type, int32_t from_index, int32_t to_index) {39switch(elem_type) {40case JVM_T_INT:41avx2_fast_sort((int32_t*)array, from_index, to_index, INSERTION_SORT_THRESHOLD_32BIT);42break;43case JVM_T_FLOAT:44avx2_fast_sort((float*)array, from_index, to_index, INSERTION_SORT_THRESHOLD_32BIT);45break;46default:47assert(false, "Unexpected type");48}49}50
51DLL_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) {52switch(elem_type) {53case JVM_T_INT:54avx2_fast_partition((int32_t*)array, from_index, to_index, pivot_indices, index_pivot1, index_pivot2);55break;56case JVM_T_FLOAT:57avx2_fast_partition((float*)array, from_index, to_index, pivot_indices, index_pivot1, index_pivot2);58break;59default:60assert(false, "Unexpected type");61}62}63
64}
65
66#endif