Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions src/include/ablas.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
/* ************************************************************************
* Copyright 2015 Advanced Micro Devices, Inc.
* Copyright 2016 Advanced Micro Devices, Inc.
*
* 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.
* ************************************************************************ */

/*!\file
Expand All @@ -24,9 +13,11 @@
#define _ABLAS_H_

#include <stdbool.h>
#include "ablas_hip.h"
#include "ablas_runtime.h"

#include "ablas_types.h"

#include "ablas_common"
#include "ablas_netlib.h"
#include "ablas_netlib_batched.h"
#include "ablas_export.h"
Expand Down
40 changes: 40 additions & 0 deletions src/include/ablas_common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/* ************************************************************************
* Copyright 2016 Advanced Micro Devices, Inc.
*
* ************************************************************************ */

#pragma once
#ifndef _ABLAS_COMMON_H_
#define _ABLAS_COMMON_H_

#include "ablas_types.h"


/*!\file
* \brief provide some common integer operations.
*/


/* ============================================================================================ */
/* integer functions */

/*! \brief For integers x >= 0, y > 0, returns ceil( x/y ).
* For x == 0, this is 0.
*/
__host__ __device__
static inline ablas_int ablas_ceildiv( ablas_int x, ablas_int y )
{
return (x + y - 1)/y;
}

/*! \brief For integers x >= 0, y > 0, returns x rounded up to multiple of y.
* For x == 0, this is 0. y is not necessarily a power of 2.
*/
__host__ __device__
static inline ablas_int ablas_roundup( ablas_int x, ablas_int y )
{
return ablas_ceildiv( x, y ) * y;
}


#endif
13 changes: 1 addition & 12 deletions src/include/ablas_expert.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
/* ************************************************************************
* Copyright 2015 Advanced Micro Devices, Inc.
* Copyright 2016 Advanced Micro Devices, Inc.
*
* 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.
* ************************************************************************ */

/*! \file
Expand Down
81 changes: 81 additions & 0 deletions src/include/ablas_hip.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/* ************************************************************************
* Copyright 2016 Advanced Micro Devices, Inc.
*
* ************************************************************************ */

#pragma once
#ifndef _ABLAS_HIP_H_
#define _ABLAS_HIP_H_

#include <hip_runtime.h>

/*!\file
* \brief ABLAS interface with HIP APIs: memory allocation, device management
*/


typedef hipStream_t ablas_queue;
typedef hipEvent_t ablas_event;
typedef ablas_queue ablas_handle;


/* ============================================================================================ */
/**
* @brief ablas error codes definition, incorporating HIP error
* definitions.
*
* This enumeration is a subset of the HIP error codes extended with some
* additional extra codes. For example, hipErrorMemoryAllocation, which is
* defined in hip_runtime_api.h is aliased as ablas_error_memory_allocation.
*/
typedef enum ablas_status_ {

ablas_success = hipSuccess = 0, ///< Successful completion.
ablas_error_memory_allocation = hipErrorMemoryAllocation, ///< Memory allocation error.
ablas_error_memory_free = hipErrorMemoryFree, ///< Memory free error.
ablas_error_unknown_symbol = hipErrorUnknownSymbol, ///< Unknown symbol
ablas_error_outof_resources = hipErrorOutOfResources ///< Out of resources error
ablas_error_invalid_value = hipErrorInvalidValue ///< One or more of the paramters passed to the API call is NULL or not in an acceptable range.
ablas_error_invalid_resource_handle = hipErrorInvalidResourceHandle ///< Resource handle (hipEvent_t or hipStream_t) invalid.
ablas_error_invalid_device = hipErrorInvalidDevice ///< DeviceID must be in range 0...#compute-devices.
ablas_error_no_deive = hipErrorNoDevice ///< Call to cudaGetDeviceCount returned 0 devices
ablas_error_not_ready = hipErrorNotReady ///< indicates that asynchronous operations enqueued earlier are not ready.
/// This is not actually an error, but is used to distinguish from hipSuccess(which indicates completion).
/// APIs that return this error include hipEventQuery and hipStreamQuery.
/* Extended error codes */
ablas_not_implemented = -1024, /**< Functionality is not implemented */
ablas_not_initialized, /**< ablas library is not initialized yet */
ablas_invalid_matA, /**< Matrix A is not a valid memory object */
ablas_invalid_matB, /**< Matrix B is not a valid memory object */
ablas_invalid_matC, /**< Matrix C is not a valid memory object */
ablas_invalid_vecX, /**< Vector X is not a valid memory object */
ablas_invalid_becY, /**< Vector Y is not a valid memory object */
ablas_invalid_dim, /**< An input dimension (M,N,K) is invalid */
ablas_invalid_leadDimA, /**< Leading dimension A must not be less than the size of the first dimension */
ablas_invalid_leadDimB, /**< Leading dimension B must not be less than the size of the second dimension */
ablas_invalid_leadDimC, /**< Leading dimension C must not be less than the size of the third dimension */
ablas_invalid_incx, /**< The increment for a vector X must not be 0 */
ablas_invalid_incy, /**< The increment for a vector Y must not be 0 */
} ablas_status;




/* ============================================================================================ */
/*! \brief memory allocation on GPU devie memory */
template<class T>
ablas_status
ablas_malloc_device(T** ptr, size_t bytes ){
return hipMalloc(ptr, bytes);
};

/*! \brief memory allocation on GPU host pinned memmory */
template<class T>
ablas_status
ablas_malloc_host(T** ptr, size_t bytes ){
return hipMallocHost(ptr, bytes);
};


#endif

15 changes: 2 additions & 13 deletions src/include/ablas_netlib.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
/* ************************************************************************
* Copyright 2013 Advanced Micro Devices, Inc.
* Copyright 2016 Advanced Micro Devices, Inc.
*
* 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.
* ************************************************************************/
* ************************************************************************ */

#pragma once
#ifndef _ABLAS_NETLIB_H_
Expand Down
15 changes: 2 additions & 13 deletions src/include/ablas_netlib_batched.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
/* ************************************************************************
* Copyright 2013 Advanced Micro Devices, Inc.
* Copyright 2016 Advanced Micro Devices, Inc.
*
* 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.
* ************************************************************************/
* ************************************************************************ */

#pragma once
#ifndef _ABLAS_BATCHED_H_
Expand Down
Loading