-
Notifications
You must be signed in to change notification settings - Fork 555
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #165 from rapidsai/branch-0.5
[gpuCI] Auto-merge branch-0.5 to branch-0.6 [skip ci]
- Loading branch information
Showing
8 changed files
with
96 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
# Copyright (c) 2018, NVIDIA CORPORATION. | ||
# Versioneer | ||
from cuML import numba_utils | ||
|
||
from ._version import get_versions | ||
__version__ = get_versions()['version'] | ||
del get_versions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# Copyright (c) 2018, NVIDIA CORPORATION. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
import numpy as np | ||
import pandas as pd | ||
import cudf | ||
import numba | ||
from librmm_cffi import librmm as rmm | ||
from numba.cuda.cudadrv.driver import driver | ||
import math | ||
from numba import cuda | ||
|
||
|
||
def row_matrix(df): | ||
"""Compute the C (row major) version gpu matrix of df | ||
This implements the algorithm documented in | ||
http://devblogs.nvidia.com/parallelforall/efficient-matrix-transpose-cuda-cc/ | ||
:param a: an `np.ndarray` or a `DeviceNDArrayBase` subclass. If already on | ||
the device its stream will be used to perform the transpose (and to copy | ||
`b` to the device if necessary). | ||
Adapted from numba: | ||
https://github.com/numba/numba/blob/master/numba/cuda/kernels/transpose.py | ||
To be replaced by CUDA ml-prim in upcoming version | ||
""" | ||
|
||
cols = [df._cols[k] for k in df._cols] | ||
ncol = len(cols) | ||
nrow = len(df) | ||
dtype = cols[0].dtype | ||
|
||
a = df.as_gpu_matrix(order='F') | ||
b = rmm.device_array((nrow, ncol), dtype=dtype, order='C') | ||
dtype = numba.typeof(a) | ||
|
||
tpb = driver.get_device().MAX_THREADS_PER_BLOCK | ||
|
||
tile_width = int(math.pow(2, math.log(tpb, 2) / 2)) | ||
tile_height = int(tpb / tile_width) | ||
|
||
tile_shape = (tile_height, tile_width + 1) | ||
|
||
@cuda.jit | ||
def kernel(input, output): | ||
|
||
tile = cuda.shared.array(shape=tile_shape, dtype=numba.float32) | ||
|
||
tx = cuda.threadIdx.x | ||
ty = cuda.threadIdx.y | ||
bx = cuda.blockIdx.x * cuda.blockDim.x | ||
by = cuda.blockIdx.y * cuda.blockDim.y | ||
y = by + tx | ||
x = bx + ty | ||
|
||
if by + ty < input.shape[0] and bx + tx < input.shape[1]: | ||
tile[ty, tx] = input[by + ty, bx + tx] | ||
cuda.syncthreads() | ||
if y < output.shape[0] and x < output.shape[1]: | ||
output[y, x] = tile[tx, ty] | ||
|
||
# one block per tile, plus one for remainders | ||
blocks = int((b.shape[1]) / tile_height + 1), int((b.shape[0]) / tile_width + 1) | ||
# one thread per tile element | ||
threads = tile_height, tile_width | ||
kernel[blocks, threads](a, b) | ||
|
||
return b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters